Struct snarkos_node_router::Peer
source · 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,
challenge_request: &ChallengeRequest<N>
) -> Self
pub fn new( listening_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 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> RefUnwindSafe for Peer<N>where <N as Environment>::Projective: RefUnwindSafe,
impl<N> Send for Peer<N>
impl<N> Sync for Peer<N>
impl<N> Unpin for Peer<N>where <N as Environment>::Projective: Unpin,
impl<N> UnwindSafe for Peer<N>where <N as Environment>::Projective: UnwindSafe,
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