pub struct PeerQos {
pub peer_id: String,
pub rtt_ewma_ms: Option<f64>,
pub challenge_success_ewma: f64,
pub last_ping_at: Option<u64>,
pub challenges_sent: u64,
pub challenges_succeeded: u64,
pub fault_score: u8,
}Expand description
Live QoS data for a single remote Pouch peer.
Serialisable so that it can be persisted across daemon restarts or
gossipped as part of a ChallengeResult announcement.
Fields§
§peer_id: Stringlibp2p PeerId (base58).
rtt_ewma_ms: Option<f64>EWMA round-trip time in milliseconds. None until the first Ping
response is received.
challenge_success_ewma: f64EWMA of challenge success rate in [0.0, 1.0].
Starts at 1.0 (benefit of the doubt).
last_ping_at: Option<u64>Unix timestamp (seconds) of the most recent Ping exchange.
challenges_sent: u64Total Ping + PoS challenges sent.
challenges_succeeded: u64Total successful challenge responses received.
fault_score: u8Accumulated fault score in [0, 100].
Incremented by FAULT_INCREMENT on each failed Proof-of-Storage
challenge; decremented by FAULT_DECAY on each success.
At FAULT_DEGRADED (70) no new fragments are sent; at
FAULT_SUSPECTED (90) preventive recoding begins; at
FAULT_BLACKLISTED (100) the peer is evicted.
Implementations§
Source§impl PeerQos
impl PeerQos
Sourcepub fn new(peer_id: impl Into<String>) -> Self
pub fn new(peer_id: impl Into<String>) -> Self
Create a fresh QoS record for a newly discovered peer.
Sourcepub fn record_ping(&mut self, rtt_ms: f64)
pub fn record_ping(&mut self, rtt_ms: f64)
Incorporate a new RTT sample (milliseconds) into the EWMA.
Also updates last_ping_at to the current UTC time.
Sourcepub fn record_ping_timeout(&mut self)
pub fn record_ping_timeout(&mut self)
Record the outcome of a Ping timeout (no response within deadline).
The latency component decays toward 0 by increasing the EWMA with a very large RTT value (10 × reference), signalling poor reachability.
Sourcepub fn record_challenge(&mut self, success: bool)
pub fn record_challenge(&mut self, success: bool)
Incorporate the result of a challenge (Ping or Proof-of-Storage).
success = true → response was received and validated.
success = false → response timed out or proof was invalid.
Sourcepub fn record_pos_success(&mut self)
pub fn record_pos_success(&mut self)
Record a successful Proof-of-Storage response.
Decays fault_score by FAULT_DECAY and records a successful
challenge in the reliability EWMA.
Sourcepub fn record_pos_failure(&mut self)
pub fn record_pos_failure(&mut self)
Record a failed Proof-of-Storage response (timeout or invalid proof).
Increments fault_score by FAULT_INCREMENT (capped at 100) and
records a failed challenge in the reliability EWMA.
Sourcepub fn fault_status(&self) -> &'static str
pub fn fault_status(&self) -> &'static str
Current fault status derived from Self::fault_score.
Returns "ok", "degraded", "suspected", or "blacklisted".
Sourcepub fn latency_score(&self) -> f64
pub fn latency_score(&self) -> f64
Latency component of the stability score: exp(−rtt_ewma / RTT_REF_MS).
Returns 0.0 if no Ping has been recorded yet.
Sourcepub fn stability_score(&self) -> f64
pub fn stability_score(&self) -> f64
Composite stability score in [0.0, 1.0].
s = W_LATENCY · latency_score + W_RELIABILITY · challenge_success_ewmaThis value feeds directly into coding::params::compute_coding_params to
determine the recovery threshold k for a target high probability Ph.
Sourcepub fn is_observed(&self) -> bool
pub fn is_observed(&self) -> bool
Whether the peer has been pinged at all.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PeerQos
impl<'de> Deserialize<'de> for PeerQos
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PeerQos
impl RefUnwindSafe for PeerQos
impl Send for PeerQos
impl Sync for PeerQos
impl Unpin for PeerQos
impl UnwindSafe for PeerQos
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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