pub struct RoutingTable { /* private fields */ }Expand description
Simplified Kademlia routing table
Implementations§
Source§impl RoutingTable
impl RoutingTable
Sourcepub fn new(id: Id) -> Self
pub fn new(id: Id) -> Self
Create a new RoutingTable with a given id.
Sourcepub fn add(&mut self, node: Node) -> bool
pub fn add(&mut self, node: Node) -> bool
Attempts to add a node to this routing table, and return true if it did.
Sourcepub fn closest(&self, target: Id) -> Box<[Node]>
pub fn closest(&self, target: Id) -> Box<[Node]>
Return the closest nodes to the target while prioritizing secure nodes, as defined in BEP_0042
Sourcepub fn closest_secure(
&self,
target: Id,
dht_size_estimate: usize,
subnets: usize,
) -> Vec<Node>
pub fn closest_secure( &self, target: Id, dht_size_estimate: usize, subnets: usize, ) -> Vec<Node>
Secure version of Self::closest that tries to circumvent sybil attacks.
Sourcepub fn nodes(&self) -> RoutingTableIterator<'_>
pub fn nodes(&self) -> RoutingTableIterator<'_>
Returns an iterator over the nodes in this routing table.
Sourcepub fn to_owned_nodes(&self) -> Vec<Node>
pub fn to_owned_nodes(&self) -> Vec<Node>
Export an owned vector of nodes from this routing table.
Sourcepub fn to_bootstrap(&self) -> Vec<String>
pub fn to_bootstrap(&self) -> Vec<String>
Turn this routing table to a list of bootstrapping nodes.
Trait Implementations§
Source§impl Clone for RoutingTable
impl Clone for RoutingTable
Source§fn clone(&self) -> RoutingTable
fn clone(&self) -> RoutingTable
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RoutingTable
impl RefUnwindSafe for RoutingTable
impl Send for RoutingTable
impl Sync for RoutingTable
impl Unpin for RoutingTable
impl UnwindSafe for RoutingTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more