Skip to content

Commit

Permalink
Fix removal of addresses from Kademlia to account for identity in mul…
Browse files Browse the repository at this point in the history
…tiaddress
  • Loading branch information
nazar-pc committed Nov 18, 2023
1 parent 1be6fac commit 185767c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/subspace-networking/src/node_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ where
});

if full_kademlia_support {
let received_address_strings = info
.listen_addrs
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>();
let old_addresses = kademlia
.kbucket(peer_id)
.and_then(|peers| {
Expand All @@ -742,7 +747,14 @@ where
peer.node
.value
.iter()
.filter(|address| !info.listen_addrs.contains(address))
.filter(|existing_address| {
let existing_address = existing_address.to_string();

!received_address_strings.iter().any(|received_address| {
received_address.starts_with(&existing_address)
|| existing_address.starts_with(received_address)
})
})
.cloned()
.collect::<Vec<_>>(),
)
Expand Down

0 comments on commit 185767c

Please sign in to comment.