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

Restore removal of old addresses #2244

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Changes from 1 commit
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
55 changes: 27 additions & 28 deletions crates/subspace-networking/src/node_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,34 +733,22 @@ where
});

if full_kademlia_support {
//TODO: Consider restoring obsolete address removal
// let old_addresses = kademlia
// .kbucket(peer_id)
// .and_then(|peers| {
// let key = peer_id.into();
// peers.iter().find_map(|peer| {
// (peer.node.key == &key).then_some(
// peer.node
// .value
// .iter()
// .filter(|address| info.listen_addrs.contains(address))
// .cloned()
// .collect::<Vec<_>>(),
// )
// })
// })
// .unwrap_or_default();

// for old_address in old_addresses {
// trace!(
// %local_peer_id,
// %peer_id,
// %old_address,
// "Removing old self-reported address from Kademlia DHT",
// );
//
// kademlia.remove_address(&peer_id, &old_address);
// }
let old_addresses = kademlia
.kbucket(peer_id)
.and_then(|peers| {
let key = peer_id.into();
peers.iter().find_map(|peer| {
(peer.node.key == &key).then_some(
peer.node
.value
.iter()
.filter(|address| !info.listen_addrs.contains(address))
.cloned()
.collect::<Vec<_>>(),
)
})
})
.unwrap_or_default();

for address in info.listen_addrs {
if !self.allow_non_global_addresses_in_dht
Expand All @@ -785,6 +773,17 @@ where

kademlia.add_address(&peer_id, address);
}

for old_address in old_addresses {
trace!(
%local_peer_id,
%peer_id,
%old_address,
"Removing old self-reported address from Kademlia DHT",
);

kademlia.remove_address(&peer_id, &old_address);
}
} else {
debug!(
%local_peer_id,
Expand Down
Loading