Trait libp2p_kad::kbucket::KBucketsPeerId
source · pub trait KBucketsPeerId: Eq + Clone {
fn distance_with(&self, other: &Self) -> u32;
fn max_distance() -> usize;
}
Expand description
Trait that must be implemented on types that can be used as an identifier in a k-bucket.
Required Methods
sourcefn distance_with(&self, other: &Self) -> u32
fn distance_with(&self, other: &Self) -> u32
Computes the XOR of this value and another one. The lower the closer.
sourcefn max_distance() -> usize
fn max_distance() -> usize
Returns then number of bits that are necessary to store the distance between peer IDs. Used for pre-allocations.
Note: Returning 0 would lead to a panic.