pub struct ClosestNodes { /* private fields */ }Expand description
Manage closest nodes found in a query.
Useful to estimate the Dht size.
Implementations§
Source§impl ClosestNodes
impl ClosestNodes
Sourcepub fn new(target: Id) -> Self
pub fn new(target: Id) -> Self
Create a new instance of ClosestNodes.
Sourcepub fn take_until_secure(
&self,
previous_dht_size_estimate: usize,
average_subnets: usize,
) -> &[Node]
pub fn take_until_secure( &self, previous_dht_size_estimate: usize, average_subnets: usize, ) -> &[Node]
Take enough nodes closest to the target, until the following are satisfied:
- At least the closest
knodes (20). - The last node should be at a distance
edkwhich is the expected distance of the 20th node given previous estimations of the DHT size. - The number of subnets with unique 6 bits prefix in nodes ipv4 addresses match or exceeds the average from previous queries.
If one or more of these conditions are not met, then we just take all responding nodes and store data at them.
Sourcepub fn subnets_count(&self) -> u8
pub fn subnets_count(&self) -> u8
Count the number of subnets with unique 6 bits prefix in ipv4
Sourcepub fn dht_size_estimate(&self) -> f64
pub fn dht_size_estimate(&self) -> f64
An estimation of the Dht from the distribution of closest nodes responding to a query.
Trait Implementations§
Source§impl Clone for ClosestNodes
impl Clone for ClosestNodes
Source§fn clone(&self) -> ClosestNodes
fn clone(&self) -> ClosestNodes
Returns a duplicate 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 ClosestNodes
impl RefUnwindSafe for ClosestNodes
impl Send for ClosestNodes
impl Sync for ClosestNodes
impl Unpin for ClosestNodes
impl UnwindSafe for ClosestNodes
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