pub struct ReputationRecord {
pub peer_id: String,
pub reputation_score: i64,
pub tier: ReputationTier,
pub first_seen_at: u64,
pub last_updated_at: u64,
pub r0_lock_until: Option<u64>,
pub uptime_seconds: u64,
pub pos_challenges_sent: u64,
pub pos_challenges_passed: u64,
}Expand description
Per-peer reputation state persisted for the daemon’s lifetime.
Fields§
§peer_id: Stringlibp2p PeerId (base58).
reputation_score: i64Continuous score used for tier promotion / demotion.
tier: ReputationTierCurrent computed tier.
first_seen_at: u64Unix timestamp (seconds) when this peer was first seen.
last_updated_at: u64Unix timestamp of the last score update.
r0_lock_until: Option<u64>If set, the peer is R0-locked until this Unix timestamp.
uptime_seconds: u64Cumulative uptime seconds observed.
pos_challenges_sent: u64Total PoS challenges sent to this peer.
pos_challenges_passed: u64PoS challenges that this peer answered successfully.
Implementations§
Source§impl ReputationRecord
impl ReputationRecord
Sourcepub fn new(peer_id: impl Into<String>, now_secs: u64) -> Self
pub fn new(peer_id: impl Into<String>, now_secs: u64) -> Self
Create a brand-new reputation record for a newly discovered peer.
Sourcepub fn record_pos_challenge(
&mut self,
passed: bool,
fault_score: u8,
now_secs: u64,
)
pub fn record_pos_challenge( &mut self, passed: bool, fault_score: u8, now_secs: u64, )
PoS challenge outcome — update score and challenge counters.
Sourcepub fn credit_uptime_day(&mut self, fault_score: u8, now_secs: u64)
pub fn credit_uptime_day(&mut self, fault_score: u8, now_secs: u64)
Credit verified uptime. Call once per continuous 24 h window.
Sourcepub fn penalise_late_pause(&mut self, fault_score: u8, now_secs: u64)
pub fn penalise_late_pause(&mut self, fault_score: u8, now_secs: u64)
Apply the late-pause penalty (pause ETA overrun).
Sourcepub fn evict_without_notice(&mut self, now_secs: u64)
pub fn evict_without_notice(&mut self, now_secs: u64)
Forced eviction without notice — reset score and lock into R0 for 30 days.
Sourcepub fn recompute_tier(&mut self, fault_score: u8, now_secs: u64)
pub fn recompute_tier(&mut self, fault_score: u8, now_secs: u64)
Recompute the tier from current stats.
Call after every mutation that changes score, uptime, or PoS counters.
Sourcepub fn pos_pass_rate(&self) -> f64
pub fn pos_pass_rate(&self) -> f64
PoS pass rate in [0.0, 1.0].
Trait Implementations§
Source§impl Clone for ReputationRecord
impl Clone for ReputationRecord
Source§fn clone(&self) -> ReputationRecord
fn clone(&self) -> ReputationRecord
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReputationRecord
impl Debug for ReputationRecord
Source§impl<'de> Deserialize<'de> for ReputationRecord
impl<'de> Deserialize<'de> for ReputationRecord
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 ReputationRecord
impl RefUnwindSafe for ReputationRecord
impl Send for ReputationRecord
impl Sync for ReputationRecord
impl Unpin for ReputationRecord
impl UnwindSafe for ReputationRecord
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