pub struct DhtManager { /* private fields */ }Expand description
DHT manager for peer and content discovery
Implementations§
Source§impl DhtManager
impl DhtManager
Sourcepub fn start_provider_refresh(&mut self)
pub fn start_provider_refresh(&mut self)
Start the provider refresh background task
Sourcepub async fn track_provider(&self, cid: Cid) -> Result<()>
pub async fn track_provider(&self, cid: Cid) -> Result<()>
Track a provider record for automatic refresh
Sourcepub async fn stop_tracking(&self, cid: &Cid) -> Result<()>
pub async fn stop_tracking(&self, cid: &Cid) -> Result<()>
Stop tracking a provider record
Sourcepub fn cache_query_result(&self, cid: &Cid, peers: Vec<PeerId>)
pub fn cache_query_result(&self, cid: &Cid, peers: Vec<PeerId>)
Cache a query result
Sourcepub fn cache_peer(&self, peer_id: PeerId)
pub fn cache_peer(&self, peer_id: PeerId)
Cache a peer
Sourcepub fn is_peer_cached(&self, peer_id: &PeerId) -> bool
pub fn is_peer_cached(&self, peer_id: &PeerId) -> bool
Check if peer is in cache
Sourcepub fn get_cached_peers(&self) -> Vec<PeerId>
pub fn get_cached_peers(&self) -> Vec<PeerId>
Get all cached peers
Sourcepub fn cleanup_cache(&self)
pub fn cleanup_cache(&self)
Clean up expired cache entries
Sourcepub fn record_query_success(&self)
pub fn record_query_success(&self)
Record a successful query
Sourcepub fn record_query_failure(&self)
pub fn record_query_failure(&self)
Record a failed query
Sourcepub fn get_health(&self) -> DhtHealth
pub fn get_health(&self) -> DhtHealth
Get DHT health status
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Check if DHT is healthy
Source§impl DhtManager
impl DhtManager
Sourcepub fn record_provide(&self, cid: &str)
pub fn record_provide(&self, cid: &str)
Record that this node is providing cid so it can be re-announced later.
Delegates to an internal ProviderReannouncer stored in the DHT manager.
The reannouncer uses a 12-hour interval by default, safely below the 24-hour TTL.
Sourcepub fn get_due_for_reannouncement(&self) -> Vec<String>
pub fn get_due_for_reannouncement(&self) -> Vec<String>
Return the list of CIDs that are due for DHT re-announcement.
Production usage: hold a ProviderReannouncer alongside DhtManager and call
reannouncer.due_for_reannouncement() directly. This method is a convenience
stub that always returns an empty list when no external reannouncer is wired up.
Sourcepub fn mark_reannounced(&self, _cids: &[String])
pub fn mark_reannounced(&self, _cids: &[String])
Mark cids as having been re-announced.
Production usage: call reannouncer.mark_reannounced(cids) directly.
Trait Implementations§
Source§impl Drop for DhtManager
impl Drop for DhtManager
Auto Trait Implementations§
impl !RefUnwindSafe for DhtManager
impl !UnwindSafe for DhtManager
impl Freeze for DhtManager
impl Send for DhtManager
impl Sync for DhtManager
impl Unpin for DhtManager
impl UnsafeUnpin for DhtManager
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