pub struct GossipState {
pub seen: HashMap<String, u64>,
}Expand description
Tracks the highest sequence number seen from each peer to deduplicate messages.
Fields§
§seen: HashMap<String, u64>Maps peer_id → highest sequence observed so far.
Implementations§
Source§impl GossipState
impl GossipState
Sourcepub fn is_new(&self, peer_id: &str, sequence: u64) -> bool
pub fn is_new(&self, peer_id: &str, sequence: u64) -> bool
Returns true when sequence is strictly greater than the last recorded value
for peer_id (or when the peer has never been seen).
Sourcepub fn record(&mut self, peer_id: &str, sequence: u64)
pub fn record(&mut self, peer_id: &str, sequence: u64)
Advance (or initialise) the tracked sequence for peer_id.
Only updates when sequence is greater than the currently stored value.
Sourcepub fn prune_stale(&mut self, threshold_seq: u64)
pub fn prune_stale(&mut self, threshold_seq: u64)
Remove all peers whose highest recorded sequence is ≤ threshold_seq.
Useful for cleaning up stale entries from long-gone peers.
Trait Implementations§
Source§impl Debug for GossipState
impl Debug for GossipState
Source§impl Default for GossipState
impl Default for GossipState
Source§fn default() -> GossipState
fn default() -> GossipState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for GossipState
impl RefUnwindSafe for GossipState
impl Send for GossipState
impl Sync for GossipState
impl Unpin for GossipState
impl UnsafeUnpin for GossipState
impl UnwindSafe for GossipState
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
Mutably borrows from an owned value. Read more
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>
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