pub struct Peer {
pub addr: PeerAddr,
pub reputation: i32,
pub state: PeerConnectionState,
pub fork_id: Option<ForkId>,
pub remove_after_disconnect: bool,
pub kind: PeerKind,
pub backed_off: bool,
pub severe_backoff_counter: u8,
}
Expand description
Tracks info about a single peer.
Fields§
§addr: PeerAddr
Where to reach the peer.
reputation: i32
Reputation of the peer.
state: PeerConnectionState
The state of the connection, if any.
fork_id: Option<ForkId>
The [ForkId
] that the peer announced via discovery.
remove_after_disconnect: bool
Whether the entry should be removed after an existing session was terminated.
kind: PeerKind
The kind of peer
backed_off: bool
Whether the peer is currently backed off.
severe_backoff_counter: u8
Counts number of times the peer was backed off due to a severe
BackoffKind
.
Implementations§
Source§impl Peer
impl Peer
Sourcepub const fn reputation(&self) -> i32
pub const fn reputation(&self) -> i32
Returns the reputation of the peer
Sourcepub fn with_state(addr: PeerAddr, state: PeerConnectionState) -> Self
pub fn with_state(addr: PeerAddr, state: PeerConnectionState) -> Self
Returns a new peer for given PeerAddr
and PeerConnectionState
.
Sourcepub fn reset_reputation(&mut self) -> ReputationChangeOutcome
pub fn reset_reputation(&mut self) -> ReputationChangeOutcome
Resets the reputation of the peer to the default value. This always returns
ReputationChangeOutcome::None
.
Sourcepub fn apply_reputation(&mut self, reputation: i32) -> ReputationChangeOutcome
pub fn apply_reputation(&mut self, reputation: i32) -> ReputationChangeOutcome
Applies a reputation change to the peer and returns what action should be taken.
Sourcepub const fn is_banned(&self) -> bool
pub const fn is_banned(&self) -> bool
Returns true if the peer’s reputation is below the banned threshold.
Sourcepub const fn is_backed_off(&self) -> bool
pub const fn is_backed_off(&self) -> bool
Returns true
if peer is banned.
Sourcepub const fn is_trusted(&self) -> bool
pub const fn is_trusted(&self) -> bool
Returns whether this peer is trusted
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Peer
impl RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl UnwindSafe for Peer
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>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 104 bytes