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

protocols/kad: Add Kademlia::get_closest_local_peers #2436

Merged
merged 15 commits into from
Jan 22, 2022
8 changes: 8 additions & 0 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,14 @@ where
self.queries.add_iter_closest(target.clone(), peers, inner)
}

/// Returns closest peers to the given key; takes peers from local routing table only.
pub fn get_closest_local_peers<'a, K: Clone>(
&'a mut self,
key: &'a kbucket::Key<K>,
) -> impl Iterator<Item = kbucket::Key<PeerId>> + 'a {
self.kbuckets.closest_keys(key)
}

/// Performs a lookup for a record in the DHT.
///
/// The result of this operation is delivered in a
Expand Down