pub struct Peer<N: Network> { /* private fields */ }
Expand description
The state for each connected peer.
Implementations§
Source§impl<N: Network> Peer<N>
impl<N: Network> Peer<N>
Sourcepub fn new(
listening_ip: SocketAddr,
connected_ip: SocketAddr,
challenge_request: &ChallengeRequest<N>,
) -> Self
pub fn new( listening_ip: SocketAddr, connected_ip: SocketAddr, challenge_request: &ChallengeRequest<N>, ) -> Self
Initializes a new instance of Peer
.
Sourcepub const fn ip(&self) -> SocketAddr
pub const fn ip(&self) -> SocketAddr
Returns the IP address of the peer, with the port set to the listener port.
Sourcepub const fn addr(&self) -> SocketAddr
pub const fn addr(&self) -> SocketAddr
Returns the connected address of the peer.
Sourcepub const fn is_validator(&self) -> bool
pub const fn is_validator(&self) -> bool
Returns true
if the peer is a validator.
Sourcepub fn first_seen(&self) -> Instant
pub fn first_seen(&self) -> Instant
Returns the first seen timestamp of the peer.
Source§impl<N: Network> Peer<N>
impl<N: Network> Peer<N>
Sourcepub fn set_node_type(&mut self, node_type: NodeType)
pub fn set_node_type(&mut self, node_type: NodeType)
Updates the node type.
Sourcepub fn set_version(&mut self, version: u32)
pub fn set_version(&mut self, version: u32)
Updates the version.
Sourcepub fn set_last_seen(&mut self, last_seen: Instant)
pub fn set_last_seen(&mut self, last_seen: Instant)
Updates the last seen timestamp of the peer.
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for Peer<N>
impl<N> RefUnwindSafe for Peer<N>
impl<N> Send for Peer<N>
impl<N> Sync for Peer<N>
impl<N> Unpin for Peer<N>
impl<N> UnwindSafe for Peer<N>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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