pub struct PeerScore {
pub peer_id: String,
pub topic_scores: HashMap<String, TopicScore>,
pub behaviour_penalties: f64,
pub app_specific_score: f64,
pub last_decay: Instant,
}Expand description
Scoring state for a single peer.
Fields§
§peer_id: StringIdentifier of the peer.
topic_scores: HashMap<String, TopicScore>Per-topic scoring data.
behaviour_penalties: f64Accumulated behaviour penalty sum.
app_specific_score: f64Application-layer score modifier.
last_decay: InstantTime of the last decay pass.
Implementations§
Source§impl PeerScore
impl PeerScore
Sourcepub fn composite_score(&self, params: &ScoreParameter) -> f64
pub fn composite_score(&self, params: &ScoreParameter) -> f64
Compute the composite score combining topic, delivery, and behaviour
components, weighted by params.
composite = Σ(topic_score_i) * topic_weight
+ behaviour_penalties * behaviour_weight
+ app_specific_score * delivery_weightSourcepub fn apply_penalty(&mut self, p: BehaviourPenalty)
pub fn apply_penalty(&mut self, p: BehaviourPenalty)
Apply a behaviour penalty to this peer.
Sourcepub fn record_first_delivery(&mut self, topic: &str)
pub fn record_first_delivery(&mut self, topic: &str)
Record that this peer was the first to deliver a message on topic.
Sourcepub fn record_mesh_delivery(&mut self, topic: &str)
pub fn record_mesh_delivery(&mut self, topic: &str)
Record a mesh message delivery for topic.
Sourcepub fn record_invalid_message(&mut self, topic: &str)
pub fn record_invalid_message(&mut self, topic: &str)
Record an invalid message on topic and increase the
invalid_message_deliveries counter.
Sourcepub fn set_in_mesh(&mut self, topic: &str, in_mesh: bool)
pub fn set_in_mesh(&mut self, topic: &str, in_mesh: bool)
Update the in-mesh flag for topic.
Sourcepub fn decay(&mut self, params: &ScoreParameter)
pub fn decay(&mut self, params: &ScoreParameter)
Decay all numeric score fields based on time elapsed since the last decay.
Decay factor: 0.9 ^ (elapsed_secs / decay_interval_secs)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerScore
impl RefUnwindSafe for PeerScore
impl Send for PeerScore
impl Sync for PeerScore
impl Unpin for PeerScore
impl UnsafeUnpin for PeerScore
impl UnwindSafe for PeerScore
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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