pub struct PeerTracker { /* private fields */ }Expand description
Bounded cache mapping blob hashes to the peers observed serving them.
len() returns the number of unique blob hashes tracked, not the total
number of peers. Use peer_count for per-blob counts.
Implementations§
Source§impl PeerTracker
impl PeerTracker
pub fn new(max_cache_size: usize, strategy: EvictionStrategy) -> Self
pub fn with_expiry( max_cache_size: usize, strategy: EvictionStrategy, expiry: Duration, ) -> Self
pub fn record_peer(&mut self, blob_hash: Hash, node_id: PublicKey)
pub fn get_peers(&mut self, blob_hash: &Hash) -> Vec<PublicKey>
pub fn peer_count(&self, blob_hash: &Hash) -> usize
pub fn contains(&self, blob_hash: &Hash, node_id: &PublicKey) -> bool
Sourcepub fn on_peer_disconnected(&mut self, node_id: &PublicKey)
pub fn on_peer_disconnected(&mut self, node_id: &PublicKey)
Remove a peer from all cached blob availability records.
pub fn is_fresh(&self, blob_hash: &Hash) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn tick_and_maybe_evict(&mut self)
Trait Implementations§
Source§impl Clone for PeerTracker
impl Clone for PeerTracker
Auto Trait Implementations§
impl Freeze for PeerTracker
impl RefUnwindSafe for PeerTracker
impl Send for PeerTracker
impl Sync for PeerTracker
impl Unpin for PeerTracker
impl UnsafeUnpin for PeerTracker
impl UnwindSafe for PeerTracker
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
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
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> ⓘ
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