mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Send validator telemetry to the private overlay (#1325)
* Send validator telemetry to the private overlay * Improve rotating neighbours in overlays
This commit is contained in:
parent
52b010ff34
commit
061c82f89c
30 changed files with 426 additions and 13 deletions
|
@ -68,6 +68,9 @@ void OverlayManager::register_overlay(adnl::AdnlNodeIdShort local_id, OverlayIdS
|
|||
}
|
||||
overlays_[local_id][overlay_id] = OverlayDescription{std::move(overlay), std::move(cert)};
|
||||
|
||||
if (!with_db_) {
|
||||
return;
|
||||
}
|
||||
auto P =
|
||||
td::PromiseCreator::lambda([id = overlays_[local_id][overlay_id].overlay.get()](td::Result<DbType::GetResult> R) {
|
||||
R.ensure();
|
||||
|
@ -417,13 +420,19 @@ OverlayManager::OverlayManager(std::string db_root, td::actor::ActorId<keyring::
|
|||
}
|
||||
|
||||
void OverlayManager::start_up() {
|
||||
std::shared_ptr<td::KeyValue> kv =
|
||||
std::make_shared<td::RocksDb>(td::RocksDb::open(PSTRING() << db_root_ << "/overlays").move_as_ok());
|
||||
db_ = DbType{std::move(kv)};
|
||||
if (!db_root_.empty()) {
|
||||
with_db_ = true;
|
||||
std::shared_ptr<td::KeyValue> kv =
|
||||
std::make_shared<td::RocksDb>(td::RocksDb::open(PSTRING() << db_root_ << "/overlays").move_as_ok());
|
||||
db_ = DbType{std::move(kv)};
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayManager::save_to_db(adnl::AdnlNodeIdShort local_id, OverlayIdShort overlay_id,
|
||||
std::vector<OverlayNode> nodes) {
|
||||
if (!with_db_) {
|
||||
return;
|
||||
}
|
||||
std::vector<tl_object_ptr<ton_api::overlay_node>> nodes_vec;
|
||||
for (auto &n : nodes) {
|
||||
nodes_vec.push_back(n.tl());
|
||||
|
|
|
@ -131,6 +131,7 @@ class OverlayManager : public Overlays {
|
|||
td::actor::ActorId<dht::Dht> dht_node_;
|
||||
|
||||
using DbType = td::KeyValueAsync<td::Bits256, td::BufferSlice>;
|
||||
bool with_db_ = false;
|
||||
DbType db_;
|
||||
|
||||
class AdnlCallback : public adnl::Adnl::Callback {
|
||||
|
|
|
@ -213,7 +213,7 @@ void OverlayImpl::add_peer(OverlayNode node) {
|
|||
peer_list_.peers_.insert(id, OverlayPeer(std::move(node)));
|
||||
del_some_peers();
|
||||
auto X = peer_list_.peers_.get(id);
|
||||
if (X != nullptr && peer_list_.neighbours_.size() < max_neighbours() &&
|
||||
if (X != nullptr && !X->is_neighbour() && peer_list_.neighbours_.size() < max_neighbours() &&
|
||||
!(X->get_node()->flags() & OverlayMemberFlags::DoNotReceiveBroadcasts) && X->get_id() != local_id_) {
|
||||
peer_list_.neighbours_.push_back(X->get_id());
|
||||
X->set_neighbour(true);
|
||||
|
@ -440,7 +440,7 @@ void OverlayImpl::update_neighbours(td::uint32 nodes_to_change) {
|
|||
VLOG(OVERLAY_INFO) << this << ": adding new neighbour " << X->get_id();
|
||||
peer_list_.neighbours_.push_back(X->get_id());
|
||||
X->set_neighbour(true);
|
||||
} else {
|
||||
} else if (X->is_alive()) {
|
||||
CHECK(nodes_to_change > 0);
|
||||
auto i = td::Random::fast(0, static_cast<td::uint32>(peer_list_.neighbours_.size()) - 1);
|
||||
auto Y = peer_list_.peers_.get(peer_list_.neighbours_[i]);
|
||||
|
|
|
@ -347,7 +347,12 @@ void OverlayImpl::alarm() {
|
|||
update_db_at_ = td::Timestamp::in(60.0);
|
||||
}
|
||||
|
||||
update_neighbours(0);
|
||||
if (update_neighbours_at_.is_in_past()) {
|
||||
update_neighbours(2);
|
||||
update_neighbours_at_ = td::Timestamp::in(td::Random::fast(30.0, 120.0));
|
||||
} else {
|
||||
update_neighbours(0);
|
||||
}
|
||||
alarm_timestamp() = td::Timestamp::in(1.0);
|
||||
} else {
|
||||
update_neighbours(0);
|
||||
|
|
|
@ -391,6 +391,7 @@ class OverlayImpl : public Overlay {
|
|||
td::Timestamp next_dht_store_query_ = td::Timestamp::in(1.0);
|
||||
td::Timestamp update_db_at_;
|
||||
td::Timestamp update_throughput_at_;
|
||||
td::Timestamp update_neighbours_at_;
|
||||
td::Timestamp last_throughput_update_;
|
||||
|
||||
std::unique_ptr<Overlays::Callback> callback_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue