Skip to content

Commit

Permalink
fix(node): record problematic connection issues for bad nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef authored and maqi committed Apr 1, 2024
1 parent cbc0e73 commit 873469b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sn_networking/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// permissions and limitations relating to use of the SAFE Network Software.

use crate::{
cmd::SwarmCmd,
driver::{truncate_patch_version, PendingGetClosestType, SwarmDriver},
error::{NetworkError, Result},
multiaddr_is_global, multiaddr_strip_p2p, sort_peers_by_address, CLOSE_GROUP_SIZE,
Expand Down Expand Up @@ -490,18 +491,26 @@ impl SwarmDriver {
};

if should_clean_peer {
warn!("Cleaning out peer {failed_peer_id:?}");
warn!("Tracking issue of {failed_peer_id:?}. Clearing it out for now");

if let Some(dead_peer) = self
.swarm
.behaviour_mut()
.kademlia
.remove_peer(&failed_peer_id)
{
self.connected_peers = self.connected_peers.saturating_sub(1);

self.handle_cmd(SwarmCmd::RecordNodeIssue {
peer_id: failed_peer_id,
issue: crate::NodeIssue::ConnectionIssue,
})?;

self.send_event(NetworkEvent::PeerRemoved(
*dead_peer.node.key.preimage(),
self.connected_peers,
));

self.log_kbuckets(&failed_peer_id);
let _ = self.check_for_change_in_our_close_group();
}
Expand Down

0 comments on commit 873469b

Please sign in to comment.