mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-26 11:12:18 +00:00
Adds a store_mut method to kademlia. (#1192)
* Adds a retain method to kademlia. * Add a store_mut getter to Kademlia * Removes a blank line * Changes store_mut comment appropriately * Fixes build * Return a type, not a trait
This commit is contained in:
parent
c11cb4d1a1
commit
dc4d1ea990
@ -276,6 +276,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a mutable reference to internal record store.
|
||||||
|
pub fn store_mut(&mut self) -> &mut TStore {
|
||||||
|
&mut self.records
|
||||||
|
}
|
||||||
|
|
||||||
/// Bootstraps the local node to join the DHT.
|
/// Bootstraps the local node to join the DHT.
|
||||||
///
|
///
|
||||||
/// Bootstrapping is a multi-step operation that starts with a lookup of the local node's
|
/// Bootstrapping is a multi-step operation that starts with a lookup of the local node's
|
||||||
|
@ -78,6 +78,15 @@ impl Default for MemoryRecordStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MemoryRecordStorage {
|
||||||
|
/// Retain the elements by a predicate.
|
||||||
|
pub fn retain<F>(&mut self, f: F)
|
||||||
|
where F: FnMut(&Multihash, &mut Record) -> bool
|
||||||
|
{
|
||||||
|
self.records.retain(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl RecordStore for MemoryRecordStorage {
|
impl RecordStore for MemoryRecordStorage {
|
||||||
fn get(&self, k: &Multihash) -> Option<Cow<Record>> {
|
fn get(&self, k: &Multihash) -> Option<Cow<Record>> {
|
||||||
match self.records.get(k) {
|
match self.records.get(k) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user