pub struct PeerState {
pub info: PeerInfo,
pub last_clock: VectorClock,
pub connection_state: PeerConnectionState,
pub last_seen: Option<Instant>,
pub pending_acks: HashMap<u64, Instant>,
pub rtt_estimate: Option<Duration>,
}Expand description
Tracked state for a connected peer.
Fields§
§info: PeerInfoPeer information
last_clock: VectorClockLast known clock from this peer
connection_state: PeerConnectionStateConnection state
last_seen: Option<Instant>Last message received timestamp
pending_acks: HashMap<u64, Instant>Pending acknowledgments (message_id -> sent_time)
rtt_estimate: Option<Duration>Round-trip time estimate (in milliseconds)
Implementations§
Source§impl PeerState
impl PeerState
Sourcepub fn new(info: PeerInfo, clock: VectorClock) -> Self
pub fn new(info: PeerInfo, clock: VectorClock) -> Self
Create a new peer state.
Sourcepub fn is_stale(&self, timeout: Duration) -> bool
pub fn is_stale(&self, timeout: Duration) -> bool
Check if the peer is considered stale (no recent activity).
Sourcepub fn expect_ack(&mut self, message_id: u64)
pub fn expect_ack(&mut self, message_id: u64)
Record that we sent a message requiring acknowledgment.
Sourcepub fn receive_ack(&mut self, message_id: u64)
pub fn receive_ack(&mut self, message_id: u64)
Record that we received an acknowledgment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerState
impl RefUnwindSafe for PeerState
impl Send for PeerState
impl Sync for PeerState
impl Unpin for PeerState
impl UnsafeUnpin for PeerState
impl UnwindSafe for PeerState
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