pub struct GossipOverlayManager {
pub stats: GossipStats,
/* private fields */
}Expand description
Manages the application-level gossip overlay.
All operations are thread-safe; queues and state are protected by Mutex/RwLock.
§Typical usage pattern
- Register known peers via
add_peer. - On network receive, call
receive; it deduplicates and enqueues. - Periodically call
drain_outboundto obtain (target, msg) pairs and forward them over the transport layer. - Call
drain_inboundto pull novel messages for local processing.
Fields§
§stats: GossipStatsImplementations§
Source§impl GossipOverlayManager
impl GossipOverlayManager
Sourcepub fn with_fanout(fanout: usize) -> Self
pub fn with_fanout(fanout: usize) -> Self
Create a manager with a custom fanout width.
Sourcepub fn remove_peer(&self, peer_id: &str)
pub fn remove_peer(&self, peer_id: &str)
Deregister a peer from the fanout candidate list.
Sourcepub fn peer_count(&self) -> usize
pub fn peer_count(&self) -> usize
Number of registered fanout candidate peers.
Sourcepub fn receive(&self, msg: GossipMessage) -> bool
pub fn receive(&self, msg: GossipMessage) -> bool
Process an incoming message.
Returns true when the message is novel (first time this sequence number from this
peer has been seen). When novel, the message is:
- pushed to the inbound queue for application processing, and
- pushed to the outbound queue for each fanout target.
Returns false and increments the duplicate counter when the message was already seen.
Sourcepub fn drain_inbound(&self) -> Vec<GossipMessage>
pub fn drain_inbound(&self) -> Vec<GossipMessage>
Drain and return all messages currently in the inbound queue.
Sourcepub fn drain_outbound(&self) -> Vec<(String, GossipMessage)>
pub fn drain_outbound(&self) -> Vec<(String, GossipMessage)>
Drain and return all (target_peer_id, message) pairs from the outbound queue.
Sourcepub fn broadcast(&self, msg: GossipMessage)
pub fn broadcast(&self, msg: GossipMessage)
Broadcast msg to all registered fanout peers (ignoring the message’s own
peer_id as a sender — useful for locally-originated messages).
Sourcepub fn stats_snapshot(&self) -> GossipStatsSnapshot
pub fn stats_snapshot(&self) -> GossipStatsSnapshot
A point-in-time snapshot of all gossip counters.
Trait Implementations§
Source§impl Debug for GossipOverlayManager
impl Debug for GossipOverlayManager
Source§impl Default for GossipOverlayManager
impl Default for GossipOverlayManager
Source§fn default() -> GossipOverlayManager
fn default() -> GossipOverlayManager
Auto Trait Implementations§
impl !Freeze for GossipOverlayManager
impl RefUnwindSafe for GossipOverlayManager
impl Send for GossipOverlayManager
impl Sync for GossipOverlayManager
impl Unpin for GossipOverlayManager
impl UnsafeUnpin for GossipOverlayManager
impl UnwindSafe for GossipOverlayManager
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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