Skip to content

Commit

Permalink
fix(node): avoid unnecessary dial back
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Dec 19, 2024
1 parent 3e2c5af commit 2bb74b8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ant-networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,25 @@ impl SwarmDriver {
{
let ilog2 = kbucket.range().0.ilog2();
let num_peers = kbucket.num_entries();
let mut is_bucket_full = num_peers >= K_VALUE.into();
let is_bucket_full = num_peers >= K_VALUE.into();

// check if peer_id is already a part of RT
let already_present_in_rt = kbucket
.iter()
.any(|entry| entry.node.key.preimage() == &peer_id);

// If the bucket contains any of a bootstrap node,
// consider the bucket is not full and dial back
// so that the bootstrap nodes can be replaced.
if is_bucket_full {
if let Some(peers) = self.bootstrap_peers.get(&ilog2) {
if kbucket.iter().any(|entry| {
peers.contains(entry.node.key.preimage())
}) {
is_bucket_full = false;
}
}
}
// // If the bucket contains any of a bootstrap node,
// // consider the bucket is not full and dial back
// // so that the bootstrap nodes can be replaced.
// if is_bucket_full {
// if let Some(peers) = self.bootstrap_peers.get(&ilog2) {
// if kbucket.iter().any(|entry| {
// peers.contains(entry.node.key.preimage())
// }) {
// is_bucket_full = false;
// }
// }
// }

(is_bucket_full, already_present_in_rt, ilog2)
} else {
Expand Down

0 comments on commit 2bb74b8

Please sign in to comment.