Skip to main content

Module liveness

Module liveness 

Source
Expand description

Per-peer connection liveness tracking for libp2p streams. Per-peer connection liveness tracking for libp2p streams.

LivenessStream wraps any AsyncRead + AsyncWrite value and checks an Arc<AtomicBool> liveness flag before every poll. When the swarm event loop clears the flag on ConnectionClosed / OutgoingConnectionError, the very next read or write on any wrapped substream for that peer returns Err(io::ErrorKind::ConnectionAborted).

This makes dead streams self-signal to their consumers (the per-peer reader and writer tasks in hopr-transport) without any changes to the NetworkStreamControl trait or the protocol layer.

Structsยง

LivenessRegistry ๐Ÿ”’
Shared registry mapping each peer to its connection-liveness flag.
LivenessStream ๐Ÿ”’
An AsyncRead + AsyncWrite wrapper that errors once its connection-liveness flag is cleared.