From fa2e4612f221bc5cacccf9468eae4286c99326d5 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Wed, 24 Apr 2024 15:34:18 +0300 Subject: [PATCH] kad: Put record query only to non-local peers Signed-off-by: Alexandru Vasile --- src/protocol/libp2p/kademlia/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/protocol/libp2p/kademlia/mod.rs b/src/protocol/libp2p/kademlia/mod.rs index a1c646f0..6661ddf1 100644 --- a/src/protocol/libp2p/kademlia/mod.rs +++ b/src/protocol/libp2p/kademlia/mod.rs @@ -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()),