Struct k_bucket::KBucket
[−]
[src]
pub struct KBucket {}
Methods
impl KBucket
[src]
pub fn new() -> Self
[src]
Create a new instance.
pub fn arbiter(&self)
[src]
Default arbiter function for contacts with the same id. Uses contact.vectorClock to select which contact to update the k-bucket with. Contact with larger vectorClock field will be selected. If vectorClock is the same, candidat will be selected.
pub fn distance(&self)
[src]
Default distance function. Finds the XOR distance between firstId and secondId.
pub fn add(&self)
[src]
Adds a contact to the k-bucket.
pub fn closest(&self)
[src]
Get the n closest contacts to the provided node id. "Closest" here means: closest according to the XOR metric of the contact node id.
pub fn len(&self) -> usize
[src]
Counts the total number of contacts in the tree.
pub fn is_empty(&self) -> bool
[src]
pub fn get(&self)
[src]
Retrieves the contact.
pub fn metadata(&self)
[src]
The metadata method serves as a container that can be used by implementations using k-bucket. One example is storing a timestamp to indicate the last time when a node in the bucket was responding to a ping.
pub fn remove(&self)
[src]
Removes contact with the provided id.
pub fn to_vec(&self)
[src]
Traverses the tree, putting all the contacts into one arraverses the tree, putting all the contacts into one vector.