pub struct PeerTrustManager {
pub records: HashMap<String, TrustRecord>,
}Expand description
Manages trust levels and attestations for peers in the network.
Fields§
§records: HashMap<String, TrustRecord>Trust records keyed by peer_id.
Implementations§
Source§impl PeerTrustManager
impl PeerTrustManager
Sourcepub fn set_trust(&mut self, peer_id: &str, level: TrustLevel)
pub fn set_trust(&mut self, peer_id: &str, level: TrustLevel)
Sets the base trust level for a peer. Creates the record if it does not exist.
Sourcepub fn add_attestation(&mut self, attestation: TrustAttestation)
pub fn add_attestation(&mut self, attestation: TrustAttestation)
Adds an attestation. Auto-creates the target peer record at Untrusted if missing.
Sourcepub fn effective_trust(&self, peer_id: &str, current_tick: u64) -> TrustLevel
pub fn effective_trust(&self, peer_id: &str, current_tick: u64) -> TrustLevel
Returns the effective trust level for a peer at current_tick.
Returns TrustLevel::Untrusted if the peer is not tracked.
Sourcepub fn peers_at_or_above(
&self,
min_level: TrustLevel,
current_tick: u64,
) -> Vec<&str>
pub fn peers_at_or_above( &self, min_level: TrustLevel, current_tick: u64, ) -> Vec<&str>
Returns peer IDs whose effective trust is at or above min_level, sorted alphabetically.
Sourcepub fn revoke_attestations(&mut self, attester_peer_id: &str)
pub fn revoke_attestations(&mut self, attester_peer_id: &str)
Removes all attestations issued by attester_peer_id across all peer records.
Sourcepub fn remove_peer(&mut self, peer_id: &str) -> bool
pub fn remove_peer(&mut self, peer_id: &str) -> bool
Removes a peer record. Returns true if the peer was present.
Sourcepub fn stats(&self, current_tick: u64) -> TrustManagerStats
pub fn stats(&self, current_tick: u64) -> TrustManagerStats
Returns aggregate statistics for the trust manager at current_tick.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerTrustManager
impl RefUnwindSafe for PeerTrustManager
impl Send for PeerTrustManager
impl Sync for PeerTrustManager
impl Unpin for PeerTrustManager
impl UnsafeUnpin for PeerTrustManager
impl UnwindSafe for PeerTrustManager
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> 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