Struct PeerAddresses  
pub struct PeerAddresses(/* private fields */);Expand description
Struct for tracking peers’ external addresses of the Swarm.
Implementations§
§impl PeerAddresses
 
impl PeerAddresses
pub fn new(number_of_peers: NonZero<usize>) -> PeerAddresses
pub fn new(number_of_peers: NonZero<usize>) -> PeerAddresses
Creates a PeerAddresses cache with capacity for the given number of peers.
For each peer, we will at most store 10 addresses.
pub fn on_swarm_event(&mut self, event: &FromSwarm<'_>) -> bool
pub fn on_swarm_event(&mut self, event: &FromSwarm<'_>) -> bool
Feed a FromSwarm event to this struct.
Returns whether the event changed peer’s known external addresses.
pub fn add(&mut self, peer: PeerId, address: Multiaddr) -> bool
pub fn add(&mut self, peer: PeerId, address: Multiaddr) -> bool
Adds address to cache. Appends address to the existing set if peer addresses already exist. Creates a new cache entry for peer_id if no addresses are present. Returns true if the newly added address was not previously in the cache.
Trait Implementations§
§impl Debug for PeerAddresses
 
impl Debug for PeerAddresses
§impl Default for PeerAddresses
 
impl Default for PeerAddresses
§fn default() -> PeerAddresses
 
fn default() -> PeerAddresses
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PeerAddresses
impl RefUnwindSafe for PeerAddresses
impl Send for PeerAddresses
impl Sync for PeerAddresses
impl Unpin for PeerAddresses
impl UnwindSafe for PeerAddresses
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
    T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
 
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
    T: 'a,
§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<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
 
fn instrument(self, span: Span) -> 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