Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): avoid unnecessary dial back #2551

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading