pub struct EfficientPeerCache { /* private fields */ }Expand description
Compact peer presence cache using stable integer indices.
Implementations§
Source§impl EfficientPeerCache
impl EfficientPeerCache
pub fn new() -> Self
Sourcepub fn add_presence(&mut self, hash: Hash, peer: PublicKey) -> Result<()>
pub fn add_presence(&mut self, hash: Hash, peer: PublicKey) -> Result<()>
Record that a peer can serve a blob.
§Errors
Returns an error after all u16 peer indices have been allocated.
pub fn remove_presence(&mut self, hash: &Hash, peer: &PublicKey) -> bool
pub fn has_peer(&self, hash: &Hash, peer: &PublicKey) -> bool
pub fn peers(&self, hash: &Hash) -> Vec<PublicKey>
pub const fn peer_count(&self) -> usize
pub fn active_peer_count(&self, hash: &Hash) -> usize
pub fn memory_usage(&self) -> usize
Sourcepub fn remove_peer(&mut self, peer: &PublicKey)
pub fn remove_peer(&mut self, peer: &PublicKey)
Remove a peer from every blob while retaining stable indices for peers that may be observed again later.
Trait Implementations§
Source§impl Clone for EfficientPeerCache
impl Clone for EfficientPeerCache
Source§fn clone(&self) -> EfficientPeerCache
fn clone(&self) -> EfficientPeerCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EfficientPeerCache
impl Debug for EfficientPeerCache
Source§impl Default for EfficientPeerCache
impl Default for EfficientPeerCache
Source§fn default() -> EfficientPeerCache
fn default() -> EfficientPeerCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for EfficientPeerCache
impl RefUnwindSafe for EfficientPeerCache
impl Send for EfficientPeerCache
impl Sync for EfficientPeerCache
impl Unpin for EfficientPeerCache
impl UnsafeUnpin for EfficientPeerCache
impl UnwindSafe for EfficientPeerCache
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