Skip to content

Commit

Permalink
kad: Keep only occupied entries, as vacant might have no addr
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Apr 19, 2024
1 parent db5d9ef commit 99e88d8
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/protocol/libp2p/kademlia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,7 @@ impl Kademlia {
// Put the record to the specified peers.
let peers = peers.into_iter().filter_map(|peer| {
match self.routing_table.entry(Key::from(peer)) {
// The routing table contains information about the peer address when:
// - Occupied: Established connection
// - Vacant: We'll try to establish the connection later, but the address is known.
KBucketEntry::Occupied(entry) | KBucketEntry::Vacant(entry) => Some(entry.clone()),
KBucketEntry::Occupied(entry) => Some(entry.clone()),
_ => None,
}
}).collect();
Expand Down

0 comments on commit 99e88d8

Please sign in to comment.