Struct libp2p_swarm::behaviour::PeerAddresses
source · pub struct PeerAddresses(/* private fields */);
Expand description
Struct for tracking peers’ external addresses of the Swarm
.
Implementations§
source§impl PeerAddresses
impl PeerAddresses
sourcepub fn new(number_of_peers: NonZeroUsize) -> Self
pub fn new(number_of_peers: NonZeroUsize) -> Self
Creates a PeerAddresses
cache with capacity for the given number of peers.
For each peer, we will at most store 10 addresses.
sourcepub 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.
sourcepub 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§
source§impl Debug for PeerAddresses
impl Debug for PeerAddresses
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§
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
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