Skip to content

Commit

Permalink
kad: Put record query only to non-local peers
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Apr 24, 2024
1 parent 5aafb80 commit fa2e461
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/protocol/libp2p/kademlia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@ impl Kademlia {

// Put the record to the specified peers.
let peers = peers.into_iter().filter_map(|peer| {
if peer == self.service.local_peer_id {
return None;
}

match self.routing_table.entry(Key::from(peer)) {
KBucketEntry::Occupied(entry) => Some(entry.clone()),
KBucketEntry::Vacant(entry) if !entry.addresses.is_empty() => Some(entry.clone()),
Expand Down

0 comments on commit fa2e461

Please sign in to comment.