PeerQos

Struct PeerQos 

Source
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: String

libp2p PeerId (base58).

§rtt_ewma_ms: Option<f64>

EWMA round-trip time in milliseconds. None until the first Ping response is received.

§challenge_success_ewma: f64

EWMA 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: u64

Total Ping + PoS challenges sent.

§challenges_succeeded: u64

Total successful challenge responses received.

§fault_score: u8

Accumulated 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

Source

pub fn new(peer_id: impl Into<String>) -> Self

Create a fresh QoS record for a newly discovered peer.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn fault_status(&self) -> &'static str

Current fault status derived from Self::fault_score.

Returns "ok", "degraded", "suspected", or "blacklisted".

Source

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.

Source

pub fn stability_score(&self) -> f64

Composite stability score in [0.0, 1.0].

s = W_LATENCY · latency_score + W_RELIABILITY · challenge_success_ewma

This value feeds directly into coding::params::compute_coding_params to determine the recovery threshold k for a target high probability Ph.

Source

pub fn is_observed(&self) -> bool

Whether the peer has been pinged at all.

Trait Implementations§

Source§

impl Clone for PeerQos

Source§

fn clone(&self) -> PeerQos

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeerQos

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PeerQos

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PeerQos

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,