mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-26 19:22:21 +00:00
Return iterator from local_closest_peers (#50)
This commit is contained in:
parent
43544e635a
commit
cc690f1fea
@ -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"
|
||||||
|
@ -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"
|
||||||
|
@ -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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user