pub struct ContentRoutingTable {
pub local_peer_id: String,
/* private fields */
}Expand description
DHT-aware content routing table with per-CID provider lists and affinity scoring.
Fields§
§local_peer_id: StringPeer ID of the local node (reserved for future self-announcement logic).
Implementations§
Source§impl ContentRoutingTable
impl ContentRoutingTable
Sourcepub fn new(local_peer_id: String, max_providers_per_cid: usize) -> Self
pub fn new(local_peer_id: String, max_providers_per_cid: usize) -> Self
Create a new routing table.
§Arguments
local_peer_id– string peer ID of the local node.max_providers_per_cid– bucket capacity per CID.
Sourcepub fn with_defaults(local_peer_id: String) -> Self
pub fn with_defaults(local_peer_id: String) -> Self
Create a new routing table with DEFAULT_MAX_PROVIDERS.
Sourcepub fn add_provider(
&self,
cid: &str,
entry: RoutingEntry,
) -> Result<(), RoutingError>
pub fn add_provider( &self, cid: &str, entry: RoutingEntry, ) -> Result<(), RoutingError>
Register entry as a provider for cid.
§Errors
RoutingError::DuplicateProvider– the peer is already listed.RoutingError::CapacityExceeded– the bucket is full.
Sourcepub fn remove_provider(&self, cid: &str, peer_id: &str)
pub fn remove_provider(&self, cid: &str, peer_id: &str)
Remove the provider identified by peer_id from the bucket for cid.
This is a no-op if neither the CID nor the peer is found.
Sourcepub fn evict_expired(&self, now: Instant)
pub fn evict_expired(&self, now: Instant)
Evict all entries whose TTL has elapsed relative to now.
Empty buckets are removed, and the internal eviction counter is updated.
Sourcepub fn get_providers(&self, cid: &str) -> Vec<RoutingEntry>
pub fn get_providers(&self, cid: &str) -> Vec<RoutingEntry>
Return all providers for cid sorted by affinity score (highest first).
Sourcepub fn best_provider(&self, cid: &str) -> Option<RoutingEntry>
pub fn best_provider(&self, cid: &str) -> Option<RoutingEntry>
Return the single provider with the highest affinity score, if any.
Sourcepub fn provider_count(&self) -> usize
pub fn provider_count(&self) -> usize
Return the total number of provider entries across all CIDs.
Sourcepub fn stats(&self) -> RoutingTableStats
pub fn stats(&self) -> RoutingTableStats
Return a snapshot of routing table statistics.
Auto Trait Implementations§
impl !Freeze for ContentRoutingTable
impl !RefUnwindSafe for ContentRoutingTable
impl Send for ContentRoutingTable
impl Sync for ContentRoutingTable
impl Unpin for ContentRoutingTable
impl UnsafeUnpin for ContentRoutingTable
impl UnwindSafe for ContentRoutingTable
Blanket Implementations§
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> 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