mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Handle non-alive nodes in overlays (#563)
This commit is contained in:
parent
3ff50f5f47
commit
434dc487a4
3 changed files with 75 additions and 21 deletions
|
@ -79,7 +79,17 @@ class OverlayPeer {
|
|||
td::int32 get_version() const {
|
||||
return node_.version();
|
||||
}
|
||||
|
||||
void on_ping_result(bool success) {
|
||||
if (success) {
|
||||
missed_pings_ = 0;
|
||||
} else {
|
||||
++missed_pings_;
|
||||
}
|
||||
}
|
||||
bool is_alive() const {
|
||||
return missed_pings_ < 3;
|
||||
}
|
||||
|
||||
td::uint32 throughput_out_bytes = 0;
|
||||
td::uint32 throughput_in_bytes = 0;
|
||||
|
||||
|
@ -105,6 +115,7 @@ class OverlayPeer {
|
|||
adnl::AdnlNodeIdShort id_;
|
||||
|
||||
bool is_neighbour_ = false;
|
||||
size_t missed_pings_ = 0;
|
||||
};
|
||||
|
||||
class OverlayImpl : public Overlay {
|
||||
|
@ -138,7 +149,8 @@ class OverlayImpl : public Overlay {
|
|||
alarm_timestamp() = td::Timestamp::in(1);
|
||||
}
|
||||
|
||||
void receive_random_peers(adnl::AdnlNodeIdShort src, td::BufferSlice data);
|
||||
void on_ping_result(adnl::AdnlNodeIdShort peer, bool success);
|
||||
void receive_random_peers(adnl::AdnlNodeIdShort src, td::Result<td::BufferSlice> R);
|
||||
void send_random_peers(adnl::AdnlNodeIdShort dst, td::Promise<td::BufferSlice> promise);
|
||||
void send_random_peers_cont(adnl::AdnlNodeIdShort dst, OverlayNode node, td::Promise<td::BufferSlice> promise);
|
||||
void get_overlay_random_peers(td::uint32 max_peers, td::Promise<std::vector<adnl::AdnlNodeIdShort>> promise) override;
|
||||
|
@ -281,7 +293,7 @@ class OverlayImpl : public Overlay {
|
|||
void add_peers(std::vector<OverlayNode> nodes);
|
||||
void del_some_peers();
|
||||
void del_peer(adnl::AdnlNodeIdShort id);
|
||||
OverlayPeer *get_random_peer();
|
||||
OverlayPeer *get_random_peer(bool only_alive = false);
|
||||
|
||||
td::actor::ActorId<keyring::Keyring> keyring_;
|
||||
td::actor::ActorId<adnl::Adnl> adnl_;
|
||||
|
@ -296,6 +308,8 @@ class OverlayImpl : public Overlay {
|
|||
td::Timestamp update_db_at_;
|
||||
td::Timestamp update_throughput_at_;
|
||||
td::Timestamp last_throughput_update_;
|
||||
std::set<adnl::AdnlNodeIdShort> bad_peers_;
|
||||
adnl::AdnlNodeIdShort next_bad_peer_ = adnl::AdnlNodeIdShort::zero();
|
||||
|
||||
std::unique_ptr<Overlays::Callback> callback_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue