pub struct RoutingTableAuditor {
pub buckets: Vec<BucketInfo>,
pub config: AuditorConfig,
}Expand description
Audits a DHT routing table represented as a collection of BucketInfo
entries and produces AuditFinding items describing any health issues.
Fields§
§buckets: Vec<BucketInfo>Up to 256 Kademlia k-buckets tracked by this auditor.
config: AuditorConfigConfiguration driving audit thresholds.
Implementations§
Source§impl RoutingTableAuditor
impl RoutingTableAuditor
Sourcepub fn new(config: AuditorConfig) -> Self
pub fn new(config: AuditorConfig) -> Self
Creates a new auditor with the given configuration and an empty bucket list.
Sourcepub fn add_bucket(&mut self, bucket: BucketInfo)
pub fn add_bucket(&mut self, bucket: BucketInfo)
Appends a bucket to the auditor’s bucket list.
Sourcepub fn update_bucket(
&mut self,
bucket_index: usize,
peer_count: usize,
now_secs: u64,
)
pub fn update_bucket( &mut self, bucket_index: usize, peer_count: usize, now_secs: u64, )
Updates an existing bucket identified by bucket_index. If no bucket
with that index exists a new one is inserted with
DEFAULT_MAX_CAPACITY.
Sourcepub fn audit(&self, now_secs: u64) -> Vec<AuditFinding>
pub fn audit(&self, now_secs: u64) -> Vec<AuditFinding>
Runs the full audit at time now_secs and returns all findings sorted
by severity descending (most severe first).
Checks performed:
- insufficient_peers (Error) – total peer count <
min_total_peers. - empty_buckets (Warning) – count of empty buckets >
max_empty_buckets. - stale_bucket (Warning) – each bucket whose
last_refreshed_secsis older thanstale_threshold_secs. - full_bucket (Info) – each bucket at maximum capacity.
Sourcepub fn total_peers(&self) -> usize
pub fn total_peers(&self) -> usize
Returns the total number of peers across all tracked buckets.
Sourcepub fn empty_bucket_count(&self) -> usize
pub fn empty_bucket_count(&self) -> usize
Returns the number of buckets that currently contain no peers.
Sourcepub fn stale_bucket_count(&self, now_secs: u64) -> usize
pub fn stale_bucket_count(&self, now_secs: u64) -> usize
Returns the number of buckets that have not been refreshed within the
configured stale_threshold_secs.
Trait Implementations§
Source§impl Clone for RoutingTableAuditor
impl Clone for RoutingTableAuditor
Source§fn clone(&self) -> RoutingTableAuditor
fn clone(&self) -> RoutingTableAuditor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RoutingTableAuditor
impl RefUnwindSafe for RoutingTableAuditor
impl Send for RoutingTableAuditor
impl Sync for RoutingTableAuditor
impl Unpin for RoutingTableAuditor
impl UnsafeUnpin for RoutingTableAuditor
impl UnwindSafe for RoutingTableAuditor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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>
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