pub(crate) struct LivenessRegistry(Arc<DashMap<PeerId, Arc<AtomicBool>>>);Expand description
Shared registry mapping each peer to its connection-liveness flag.
A clone of this registry is held by both crate::HoprNetwork and the
swarm event-loop closure. When libp2p reports a peer fully disconnected,
the loop calls LivenessRegistry::remove, which clears the flag and
removes the entry. Any LivenessStream that already cloned the old
Arc<AtomicBool> will see false on its next poll.
Tuple Fields§
§0: Arc<DashMap<PeerId, Arc<AtomicBool>>>Implementations§
Source§impl LivenessRegistry
impl LivenessRegistry
Sourcepub(crate) fn get_or_create_connected(&self, peer: &PeerId) -> Arc<AtomicBool>
pub(crate) fn get_or_create_connected(&self, peer: &PeerId) -> Arc<AtomicBool>
Registers peer and returns its liveness flag, creating a fresh true
flag if none exists. Call this when opening or accepting a stream.
Sourcepub(crate) fn get(&self, peer: &PeerId) -> Option<Arc<AtomicBool>>
pub(crate) fn get(&self, peer: &PeerId) -> Option<Arc<AtomicBool>>
Returns the current liveness flag for peer, or None if the peer is
not registered. Does not create an entry.
Sourcepub(crate) fn remove(&self, peer: &PeerId)
pub(crate) fn remove(&self, peer: &PeerId)
Removes peer from the registry and sets its flag to false.
Any LivenessStream still holding the old Arc will error on its
next poll. A subsequent Self::get_or_create_connected call mints a fresh true flag.
Trait Implementations§
Source§impl Clone for LivenessRegistry
impl Clone for LivenessRegistry
Source§fn clone(&self) -> LivenessRegistry
fn clone(&self) -> LivenessRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for LivenessRegistry
impl Default for LivenessRegistry
Source§fn default() -> LivenessRegistry
fn default() -> LivenessRegistry
Auto Trait Implementations§
impl Freeze for LivenessRegistry
impl !RefUnwindSafe for LivenessRegistry
impl Send for LivenessRegistry
impl Sync for LivenessRegistry
impl Unpin for LivenessRegistry
impl !UnwindSafe for LivenessRegistry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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