pub struct KBucketTable { /* private fields */ }Expand description
Bounded XOR k-bucket routing table. Caller-owned; lookup does not allocate.
Implementations§
Source§impl KBucketTable
impl KBucketTable
Sourcepub const fn new(local: StrongDigest) -> Self
pub const fn new(local: StrongDigest) -> Self
Creates a default KBucketTable.
Sourcepub const fn local_id(&self) -> StrongDigest
pub const fn local_id(&self) -> StrongDigest
KBucketTable::local_id.
Sourcepub fn insert(&mut self, id: StrongDigest) -> Result<(), QdnfError>
pub fn insert(&mut self, id: StrongDigest) -> Result<(), QdnfError>
Insert id. Duplicate IDs refresh last-seen. Distance-0 (self) is Range.
A full k-bucket or a full table is Capacity.
Sourcepub fn bootstrap(&mut self, known: &[StrongDigest]) -> Result<u8, QdnfError>
pub fn bootstrap(&mut self, known: &[StrongDigest]) -> Result<u8, QdnfError>
Insert known node IDs. Stops and fails closed on the first Capacity/Range.
Sourcepub fn closest(
&self,
target: &StrongDigest,
out: &mut [StrongDigest],
) -> Result<usize, QdnfError>
pub fn closest( &self, target: &StrongDigest, out: &mut [StrongDigest], ) -> Result<usize, QdnfError>
Up to K XOR-nearest contacts. Empty out with contacts present is Capacity.
Sourcepub fn iterative_lookup(
&self,
target: &StrongDigest,
work_budget: u8,
out: &mut [StrongDigest],
) -> Result<u8, QdnfError>
pub fn iterative_lookup( &self, target: &StrongDigest, work_budget: u8, out: &mut [StrongDigest], ) -> Result<u8, QdnfError>
Iterative FIND_NODE over the local table. Each shortlist probe costs one
work unit. Shared-table respondents cannot introduce unknown contacts.
Exhausting work_budget before every shortlist contact is probed is
QdnfError::BudgetExhausted.
Sourcepub fn maintain(&mut self) -> u16
pub fn maintain(&mut self) -> u16
Advance the last-seen clock and drop contacts older than
STALE_GENERATIONS. Returns the number of dropped entries.
Auto Trait Implementations§
impl Freeze for KBucketTable
impl RefUnwindSafe for KBucketTable
impl Send for KBucketTable
impl Sync for KBucketTable
impl Unpin for KBucketTable
impl UnsafeUnpin for KBucketTable
impl UnwindSafe for KBucketTable
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more