Return iterator from local_closest_peers (#50)

This commit is contained in:
folex 2021-06-09 18:21:30 +03:00 committed by GitHub
parent 43544e635a
commit cc690f1fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@
name = "fluence-fork-libp2p" name = "fluence-fork-libp2p"
edition = "2018" edition = "2018"
description = "Peer-to-peer networking library" description = "Peer-to-peer networking library"
version = "0.36.1" version = "0.36.2"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -2,7 +2,7 @@
name = "fluence-fork-libp2p-kad" name = "fluence-fork-libp2p-kad"
edition = "2018" edition = "2018"
description = "Kademlia protocol for libp2p" description = "Kademlia protocol for libp2p"
version = "0.29.1" version = "0.29.2"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -591,11 +591,11 @@ where
} }
/// Returns closest peers to the given key; takes peers from local routing table /// Returns closest peers to the given key; takes peers from local routing table
pub fn local_closest_peers<K>(&mut self, key: K) -> Vec<WeightedPeer> pub fn local_closest_peers<'s, 'k : 's, K: 's>(&'s mut self, key: &'k kbucket::Key<K>)
-> impl Iterator<Item = WeightedPeer> + 's
where where
K: Into<kbucket::Key<K>> + Into<Vec<u8>> + Clone { K: Into<kbucket::Key<K>> + Into<Vec<u8>> + Clone {
let target: kbucket::Key<K> = key.into(); Self::closest_keys(&mut self.kbuckets, key)
Self::closest_keys(&mut self.kbuckets, &target).collect()
} }
/// Performs a lookup for a record in the DHT. /// Performs a lookup for a record in the DHT.