pub struct ReputationManager { /* private fields */ }Expand description
Reputation manager for tracking peer reputations
Implementations§
Source§impl ReputationManager
impl ReputationManager
Sourcepub fn new(config: ReputationConfig) -> Self
pub fn new(config: ReputationConfig) -> Self
Create a new reputation manager
Sourcepub fn get_reputation(&self, peer_id: &PeerId) -> Option<ReputationScore>
pub fn get_reputation(&self, peer_id: &PeerId) -> Option<ReputationScore>
Get reputation score for a peer
Sourcepub fn is_trusted(&self, peer_id: &PeerId) -> bool
pub fn is_trusted(&self, peer_id: &PeerId) -> bool
Check if a peer is trusted based on their reputation
Sourcepub fn is_bad_peer(&self, peer_id: &PeerId) -> bool
pub fn is_bad_peer(&self, peer_id: &PeerId) -> bool
Check if a peer has a bad reputation
Sourcepub fn get_trusted_peers(&self) -> Vec<PeerId>
pub fn get_trusted_peers(&self) -> Vec<PeerId>
Get list of trusted peers
Sourcepub fn get_bad_peers(&self) -> Vec<PeerId>
pub fn get_bad_peers(&self) -> Vec<PeerId>
Get list of bad peers
Sourcepub fn record_successful_transfer(&mut self, peer_id: &PeerId, _bytes: u64)
pub fn record_successful_transfer(&mut self, peer_id: &PeerId, _bytes: u64)
Record a successful transfer
Sourcepub fn record_failed_transfer(&mut self, peer_id: &PeerId)
pub fn record_failed_transfer(&mut self, peer_id: &PeerId)
Record a failed transfer
Sourcepub fn record_low_latency(&mut self, peer_id: &PeerId, latency_ms: u64)
pub fn record_low_latency(&mut self, peer_id: &PeerId, latency_ms: u64)
Record low latency response
Sourcepub fn record_protocol_violation(&mut self, peer_id: &PeerId)
pub fn record_protocol_violation(&mut self, peer_id: &PeerId)
Record a protocol violation
Sourcepub fn update_uptime(&mut self, peer_id: &PeerId, duration: Duration)
pub fn update_uptime(&mut self, peer_id: &PeerId, duration: Duration)
Update uptime for a peer
Sourcepub fn record_event(&mut self, peer_id: &PeerId, event: ReputationEvent)
pub fn record_event(&mut self, peer_id: &PeerId, event: ReputationEvent)
Record a reputation event
Sourcepub fn apply_decay(&mut self)
pub fn apply_decay(&mut self)
Apply time-based decay to all reputation scores
Sourcepub fn cleanup_stale(&mut self) -> usize
pub fn cleanup_stale(&mut self) -> usize
Remove stale peer reputations based on retention period
Sourcepub fn tracked_peer_count(&self) -> usize
pub fn tracked_peer_count(&self) -> usize
Get the number of tracked peers
Sourcepub fn stats(&self) -> ReputationStats
pub fn stats(&self) -> ReputationStats
Get reputation statistics
Auto Trait Implementations§
impl !Freeze for ReputationManager
impl !RefUnwindSafe for ReputationManager
impl Send for ReputationManager
impl Sync for ReputationManager
impl Unpin for ReputationManager
impl UnwindSafe for ReputationManager
Blanket Implementations§
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
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