pub struct ProviderReannouncer { /* private fields */ }Expand description
Tracks which CIDs this node provides and when they were last announced.
DHT provider records expire after 24 hours. ProviderReannouncer keeps
track of the last announcement time for every CID so the caller can
periodically re-announce before expiry.
Implementations§
Source§impl ProviderReannouncer
impl ProviderReannouncer
Sourcepub fn new(reannounce_interval: Duration) -> Self
pub fn new(reannounce_interval: Duration) -> Self
Create a new reannouncer with the given interval.
Sourcepub fn with_max_per_cycle(
reannounce_interval: Duration,
max_per_cycle: usize,
) -> Self
pub fn with_max_per_cycle( reannounce_interval: Duration, max_per_cycle: usize, ) -> Self
Create a new reannouncer with a custom max-per-cycle cap.
Sourcepub fn record_provide(&mut self, cid: &str)
pub fn record_provide(&mut self, cid: &str)
Record that we started providing cid.
Calling this again for an existing CID resets its timer (treat as fresh announcement).
Sourcepub fn due_for_reannouncement(&self) -> Vec<String>
pub fn due_for_reannouncement(&self) -> Vec<String>
Return CIDs whose last announcement is older than reannounce_interval.
At most max_per_cycle entries are returned to avoid flooding the
network in a single cycle.
Sourcepub fn mark_reannounced(&mut self, cids: &[String])
pub fn mark_reannounced(&mut self, cids: &[String])
Mark a set of CIDs as re-announced, resetting their timestamps.
Sourcepub fn stats(&self) -> ReannounceStats
pub fn stats(&self) -> ReannounceStats
Return summary statistics about the tracked CIDs.
Auto Trait Implementations§
impl Freeze for ProviderReannouncer
impl RefUnwindSafe for ProviderReannouncer
impl Send for ProviderReannouncer
impl Sync for ProviderReannouncer
impl Unpin for ProviderReannouncer
impl UnsafeUnpin for ProviderReannouncer
impl UnwindSafe for ProviderReannouncer
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> 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