Struct dht::KNodeTable
[−]
[src]
pub struct KNodeTable<TId> { /* fields omitted */ }
Kademlia node table.
Keeps nodes in a number of k-buckets (equal to bit size of ID in a system, usually 160), where N-th k-bucket contains nodes with distance from 2N to 2N+1 from our node.
Methods
impl<TId> KNodeTable<TId> where TId: GenericId
[src]
fn new(this_id: TId) -> KNodeTable<TId>
Create a new node table.
this_id
-- ID of the current node (used to calculate metrics).
Trait Implementations
impl<TId> GenericNodeTable<TId> for KNodeTable<TId> where TId: GenericId
[src]
fn random_id(&self) -> TId
Generate suitable random ID.
fn update(&mut self, node: &Node<TId>) -> bool
Store or update node in the table.
fn find(&self, id: &TId, count: usize) -> Vec<Node<TId>>
Find given number of node, closest to given ID.
fn pop_oldest(&mut self) -> Vec<Node<TId>>
Pop expired or the oldest nodes from table for inspection.