QosRegistry

Struct QosRegistry 

Source
pub struct QosRegistry { /* private fields */ }
Expand description

In-memory map of peer_id → PeerQos for the local node.

Held inside DaemonState under a RwLock:

pub qos: RwLock<QosRegistry>,

Implementations§

Source§

impl QosRegistry

Source

pub fn new() -> Self

Source

pub fn entry(&mut self, peer_id: impl Into<String>) -> &mut PeerQos

Return (or lazily create) the QoS record for peer_id.

Source

pub fn get(&self, peer_id: &str) -> Option<&PeerQos>

Read-only view of a peer’s QoS; returns None if never seen.

Source

pub fn remove(&mut self, peer_id: &str)

Remove a peer (e.g. on explicit Farewell or eviction).

Source

pub fn stability_score(&self, peer_id: &str) -> f64

Stability score for peer_id. Returns 0.0 if never seen.

Source

pub fn all_stability_scores(&self) -> Vec<f64>

Snapshot of all stability scores as a Vec<f64> (order not defined).

This is the primary input to crate::coding::params::compute_coding_params.

Source

pub fn stability_scores_for<'a>( &self, pouch_peer_ids: impl Iterator<Item = &'a str>, ) -> Vec<f64>

Stability scores only for Pouch peers whose peer_id appears in pouch_peer_ids — used to scope the k-calculation to active Pouches in a specific network, rather than all connected peers.

Source

pub fn peer_count(&self) -> usize

Total number of tracked peers.

Source

pub fn peer_ids(&self) -> impl Iterator<Item = &str>

All peer IDs currently tracked.

Source

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

Fault status of a peer: "ok", "degraded", "suspected", or "blacklisted". Returns "ok" if the peer has never been seen.

Source

pub fn fault_score(&self, peer_id: &str) -> u8

Fault score of a peer in [0, 100]. Returns 0 if never seen.

Trait Implementations§

Source§

impl Debug for QosRegistry

Source§

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

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

impl Default for QosRegistry

Source§

fn default() -> QosRegistry

Returns the “default value” for a type. 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> 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, 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