Skip to content

Commit

Permalink
chore(network): remove protocol mismatch peer from RT
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and joshuef committed Jul 16, 2024
1 parent 5cda442 commit 9bddeea
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ impl SwarmDriver {
their_protocol: info.protocol_version,
});
self.remove_outdated_connections(Some(peer_id));
if let Some(dead_peer) =
self.swarm.behaviour_mut().kademlia.remove_peer(&peer_id)
{
error!("Clearing out a protocol mistmatch peer from RT. Something went wrong, we should not have added this peer to RT: {peer_id:?}");
self.update_on_peer_removal(*dead_peer.node.key.preimage());
let _ = self.check_for_change_in_our_close_group();
}

return Ok(());
}
Expand Down Expand Up @@ -667,7 +674,7 @@ impl SwarmDriver {
if let Some(p) = force_remove_peer {
if *peer_id == p {
let result = self.swarm.close_connection(*connection_id);
trace!(
debug!(
"Force removed connection {connection_id:?} to {peer_id:?} with result: {result:?}"
);
removed_conns += 1;
Expand Down Expand Up @@ -697,7 +704,7 @@ impl SwarmDriver {

// actually remove connection
let result = self.swarm.close_connection(*connection_id);
trace!("Removed outdated connection {connection_id:?} to {peer_id:?} with result: {result:?}");
debug!("Removed outdated connection {connection_id:?} to {peer_id:?} with result: {result:?}");

removed_conns += 1;

Expand Down

0 comments on commit 9bddeea

Please sign in to comment.