pub struct NodeBucketStorage { /* private fields */ }
Expand description
Implements the XOR distance-based bucketing system described in BEP0005 (more or less).
NodeBucketStorage keeps one bucket with capacity k
for each bit of the DHT’s
info hashes. Since the mainline DHT uses 20 byte (160 bit) info hashes, this
object will by default keep a maximum of 160 buckets of size k
.
As described in BEP0005, the buckets are organized according to an XOR distance metric so that Nodes with ids closer to our DHT’s Id are given the most storage space. The first bucket stores Nodes that have a zero (or more) bit prefix in common with the DHT Id. The second bucket stores Nodes that have a one (or more) bit prefix in common with the DHT Id. Two or more bits in the third. Three or more bits in the 4th. And so on.
Implementations§
Source§impl NodeBucketStorage
impl NodeBucketStorage
Sourcepub fn new(our_id: Id, k: usize) -> NodeBucketStorage
pub fn new(our_id: Id, k: usize) -> NodeBucketStorage
Create a new NodeBucketStorage.
§Parameters
our_id
- the current Id of the DHT node that will use this object for storage. Nodes will be assigned to buckets based on the XOR distance between their Id and this one.k
- the number of nodes that can be stored in a bucket.
Trait Implementations§
Source§impl Clone for NodeBucketStorage
impl Clone for NodeBucketStorage
Source§fn clone(&self) -> NodeBucketStorage
fn clone(&self) -> NodeBucketStorage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl NodeStorage for NodeBucketStorage
impl NodeStorage for NodeBucketStorage
Source§fn add_or_update(&mut self, node: Node, verified: bool)
fn add_or_update(&mut self, node: Node, verified: bool)
Source§fn count(&self) -> (usize, usize)
fn count(&self) -> (usize, usize)
last_verified
property is not None) and the number that haven’t. Read more