Skip to content

Commit

Permalink
Fix updating neighbors in private overlays (ton-blockchain#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese authored Oct 24, 2024
1 parent f82827e commit 0862cca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions overlay/overlay-peers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ void OverlayImpl::update_neighbours(td::uint32 nodes_to_change) {
continue;
}

if (X->get_version() <= td::Clocks::system() - Overlays::overlay_peer_ttl()) {
if (overlay_type_ != OverlayType::FixedMemberList && X->get_version() <= td::Clocks::system() -
Overlays::overlay_peer_ttl()) {
if (X->is_permanent_member()) {
del_from_neighbour_list(X);
} else {
Expand Down Expand Up @@ -656,14 +657,9 @@ size_t OverlayImpl::neighbours_cnt() const {

void OverlayImpl::update_root_member_list(std::vector<adnl::AdnlNodeIdShort> ids,
std::vector<PublicKeyHash> root_public_keys, OverlayMemberCertificate cert) {
td::uint32 expectd_size =
auto expected_size =
(td::uint32)(ids.size() + root_public_keys.size() * opts_.max_slaves_in_semiprivate_overlay_);
if (expectd_size > opts_.max_peers_) {
opts_.max_peers_ = expectd_size;
}
if (expectd_size > opts_.max_neighbours_) {
opts_.max_neighbours_ = expectd_size;
}
opts_.max_peers_ = std::max(opts_.max_peers_, expected_size);
std::sort(ids.begin(), ids.end());
auto old_root_public_keys = std::move(peer_list_.root_public_keys_);
for (const auto &pub_key : root_public_keys) {
Expand Down
2 changes: 1 addition & 1 deletion overlay/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Overlay : public td::actor::Actor {
bool is_response) = 0;
virtual void update_peer_ip_str(adnl::AdnlNodeIdShort peer_id, td::string ip_str) = 0;
virtual void update_member_certificate(OverlayMemberCertificate cert) = 0;
virtual void update_root_member_list(std::vector<adnl::AdnlNodeIdShort> nodes,
virtual void update_root_member_list(std::vector<adnl::AdnlNodeIdShort> ids,
std::vector<PublicKeyHash> root_public_keys, OverlayMemberCertificate cert) = 0;
//virtual void receive_broadcast(td::BufferSlice data) = 0;
//virtual void subscribe(std::unique_ptr<Overlays::Callback> callback) = 0;
Expand Down
2 changes: 1 addition & 1 deletion overlay/overlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class OverlayImpl : public Overlay {

void update_peer_ip_str(adnl::AdnlNodeIdShort peer_id, td::string ip_str) override;

void update_root_member_list(std::vector<adnl::AdnlNodeIdShort> nodes, std::vector<PublicKeyHash> root_public_keys,
void update_root_member_list(std::vector<adnl::AdnlNodeIdShort> ids, std::vector<PublicKeyHash> root_public_keys,
OverlayMemberCertificate cert) override;

bool is_valid_peer(const adnl::AdnlNodeIdShort &id, const ton_api::overlay_MemberCertificate *certificate);
Expand Down

0 comments on commit 0862cca

Please sign in to comment.