pub struct PeerStats {
pub peer_id: PeerId,
pub last_seen: Instant,
pub success_count: u32,
pub fail_count: u32,
pub avg_rtt_ms: Option<u64>,
pub last_rtt_ms: Option<u64>,
pub health: PeerHealth,
pub is_local: bool,
pub bytes_sent: u64,
pub bytes_received: u64,
}Expand description
Statistics for a single peer
Fields§
§peer_id: PeerIdUnique peer identifier
last_seen: InstantLast time we successfully communicated with this peer
success_count: u32Number of successful ping responses
fail_count: u32Number of failed pings or timeouts
avg_rtt_ms: Option<u64>Average round-trip time in milliseconds
last_rtt_ms: Option<u64>Last measured RTT
health: PeerHealthCurrent health status
is_local: boolWhether this peer is on the local network
bytes_sent: u64Total number of bytes sent to this peer
bytes_received: u64Total number of bytes received from this peer
Implementations§
Source§impl PeerStats
impl PeerStats
Sourcepub fn new(peer_id: PeerId, is_local: bool) -> Self
pub fn new(peer_id: PeerId, is_local: bool) -> Self
Create new peer stats for a discovered peer
Sourcepub fn record_success(&mut self, rtt: Duration)
pub fn record_success(&mut self, rtt: Duration)
Record a successful ping response
Sourcepub fn record_failure(&mut self)
pub fn record_failure(&mut self)
Record a failed ping or timeout
Sourcepub fn is_offline(&self, timeout: Duration) -> bool
pub fn is_offline(&self, timeout: Duration) -> bool
Check if peer should be considered offline
Sourcepub fn record_transfer(&mut self, sent: u64, received: u64)
pub fn record_transfer(&mut self, sent: u64, received: u64)
Record data transfer statistics
Sourcepub fn health_score(&self) -> u8
pub fn health_score(&self) -> u8
Calculate the overall health score (0-100)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerStats
impl RefUnwindSafe for PeerStats
impl Send for PeerStats
impl Sync for PeerStats
impl Unpin for PeerStats
impl UnwindSafe for PeerStats
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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