1
0
mirror of https://github.com/danog/ton.git synced 2024-11-30 04:29:19 +01:00
ton/dht/dht.hpp
ton 9d6853ef24 liteclient signature check support
1. update liteclient/liteserver. Now liteserver sends signatures of
blocks and liteclient checks them. I.e. liteclient completely checks
received data.
2. validator-engine: more GC options
3. blockchain-explorer: show all block transactions (instead of 256)
4. some bugfixes
2019-09-14 18:14:55 +04:00

124 lines
3.4 KiB
C++

/*
This file is part of TON Blockchain Library.
TON Blockchain Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
TON Blockchain Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP
*/
#pragma once
#include <set>
#include "td/utils/int_types.h"
#include "td/actor/actor.h"
#include "td/utils/List.h"
#include "adnl/adnl.h"
#include "adnl/utils.hpp"
#include "keys/encryptor.h"
#include "dht.h"
#include "dht-node.hpp"
#include "auto/tl/ton_api.hpp"
namespace ton {
namespace dht {
constexpr int VERBOSITY_NAME(DHT_WARNING) = verbosity_INFO;
constexpr int VERBOSITY_NAME(DHT_NOTICE) = verbosity_DEBUG;
constexpr int VERBOSITY_NAME(DHT_INFO) = verbosity_DEBUG;
constexpr int VERBOSITY_NAME(DHT_DEBUG) = verbosity_DEBUG + 1;
constexpr int VERBOSITY_NAME(DHT_EXTRA_DEBUG) = verbosity_DEBUG + 10;
class DhtGlobalConfig {
public:
auto get_k() const {
return k_;
}
auto get_a() const {
return a_;
}
const auto &nodes() const {
return static_nodes_;
}
DhtGlobalConfig(td::uint32 k, td::uint32 a, DhtNodesList nodes) : k_(k), a_(a), static_nodes_(std::move(nodes)) {
}
private:
td::uint32 k_;
td::uint32 a_;
DhtNodesList static_nodes_;
};
class DhtMember : public Dht {
public:
static constexpr td::uint32 default_k() {
return 10;
}
static constexpr td::uint32 default_a() {
return 3;
}
static constexpr td::uint32 max_k() {
return 10;
}
static constexpr td::uint32 max_a() {
return 10;
}
struct PrintId {
adnl::AdnlNodeIdShort id;
};
static td::actor::ActorOwn<DhtMember> create(adnl::AdnlNodeIdShort id, std::string db_root,
td::actor::ActorId<keyring::Keyring> keyring,
td::actor::ActorId<adnl::Adnl> adnl, td::uint32 k = 10,
td::uint32 a = 3);
//virtual void update_addr_list(tl_object_ptr<ton_api::adnl_addressList> addr_list) = 0;
//virtual void add_node(adnl::AdnlNodeIdShort id) = 0;
virtual void add_full_node(DhtKeyId id, DhtNode node) = 0;
virtual void receive_ping(DhtKeyId id, DhtNode result) = 0;
virtual void get_value_in(DhtKeyId key, td::Promise<DhtValue> result) = 0;
virtual td::Status store_in(DhtValue value) = 0;
virtual void get_self_node(td::Promise<DhtNode> promise) = 0;
virtual PrintId print_id() const = 0;
};
inline td::StringBuilder &operator<<(td::StringBuilder &sb, const DhtMember::PrintId &id) {
sb << "[dhtnode " << id.id << "]";
return sb;
}
inline td::StringBuilder &operator<<(td::StringBuilder &sb, const DhtMember &dht) {
sb << dht.print_id();
return sb;
}
inline td::StringBuilder &operator<<(td::StringBuilder &sb, const DhtMember *dht) {
sb << dht->print_id();
return sb;
}
} // namespace dht
} // namespace ton