ReputationRecord

Struct ReputationRecord 

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

libp2p PeerId (base58).

§reputation_score: i64

Continuous score used for tier promotion / demotion.

§tier: ReputationTier

Current computed tier.

§first_seen_at: u64

Unix timestamp (seconds) when this peer was first seen.

§last_updated_at: u64

Unix timestamp of the last score update.

§r0_lock_until: Option<u64>

If set, the peer is R0-locked until this Unix timestamp.

§uptime_seconds: u64

Cumulative uptime seconds observed.

§pos_challenges_sent: u64

Total PoS challenges sent to this peer.

§pos_challenges_passed: u64

PoS challenges that this peer answered successfully.

Implementations§

Source§

impl ReputationRecord

Source

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

Create a brand-new reputation record for a newly discovered peer.

Source

pub fn record_pos_challenge( &mut self, passed: bool, fault_score: u8, now_secs: u64, )

PoS challenge outcome — update score and challenge counters.

Source

pub fn credit_uptime_day(&mut self, fault_score: u8, now_secs: u64)

Credit verified uptime. Call once per continuous 24 h window.

Source

pub fn penalise_late_pause(&mut self, fault_score: u8, now_secs: u64)

Apply the late-pause penalty (pause ETA overrun).

Source

pub fn evict_without_notice(&mut self, now_secs: u64)

Forced eviction without notice — reset score and lock into R0 for 30 days.

Source

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.

Source

pub fn pos_pass_rate(&self) -> f64

PoS pass rate in [0.0, 1.0].

Trait Implementations§

Source§

impl Clone for ReputationRecord

Source§

fn clone(&self) -> ReputationRecord

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 ReputationRecord

Source§

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

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

impl<'de> Deserialize<'de> for ReputationRecord

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 ReputationRecord

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>,