pub enum Peer<N: Network> {
Candidate(CandidatePeer),
Connecting(ConnectingPeer),
Connected(ConnectedPeer<N>),
}Expand description
A peer of any connection status.
Variants§
Candidate(CandidatePeer)
A candidate peer that’s currently not connected to.
Connecting(ConnectingPeer)
A peer that’s currently being connected to (the handshake is in progress).
Connected(ConnectedPeer<N>)
A fully connected (post-handshake) peer.
Implementations§
Source§impl<N: Network> Peer<N>
impl<N: Network> Peer<N>
Sourcepub const fn new_candidate(listener_addr: SocketAddr, trusted: bool) -> Self
pub const fn new_candidate(listener_addr: SocketAddr, trusted: bool) -> Self
Create a candidate peer.
Sourcepub const fn new_connecting(listener_addr: SocketAddr, trusted: bool) -> Self
pub const fn new_connecting(listener_addr: SocketAddr, trusted: bool) -> Self
Create a connecting peer.
Sourcepub fn upgrade_to_connected(
&mut self,
connected_addr: SocketAddr,
listener_port: u16,
aleo_address: Address<N>,
node_type: NodeType,
node_version: u32,
connection_mode: ConnectionMode,
)
pub fn upgrade_to_connected( &mut self, connected_addr: SocketAddr, listener_port: u16, aleo_address: Address<N>, node_type: NodeType, node_version: u32, connection_mode: ConnectionMode, )
Promote a connecting peer to a fully connected one.
Sourcepub fn downgrade_to_candidate(&mut self, listener_addr: SocketAddr)
pub fn downgrade_to_candidate(&mut self, listener_addr: SocketAddr)
Demote a peer to candidate status, marking it as disconnected.
Sourcepub fn node_type(&self) -> Option<NodeType>
pub fn node_type(&self) -> Option<NodeType>
Returns the type of the node (only applicable to connected peers).
Sourcepub fn listener_addr(&self) -> SocketAddr
pub fn listener_addr(&self) -> SocketAddr
The listener (public) address of this peer.
Sourcepub fn last_height_seen(&self) -> Option<u32>
pub fn last_height_seen(&self) -> Option<u32>
The listener (public) address of this peer.
Sourcepub fn is_candidate(&self) -> bool
pub fn is_candidate(&self) -> bool
Returns true if the peer is not connected or connecting.
Sourcepub fn is_connecting(&self) -> bool
pub fn is_connecting(&self) -> bool
Returns true if the peer is currently undergoing the network handshake.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns true if the peer has concluded the network handshake.
Sourcepub fn is_trusted(&self) -> bool
pub fn is_trusted(&self) -> bool
Returns true if the peer is considered trusted.
Sourcepub fn update_last_seen(&mut self)
pub fn update_last_seen(&mut self)
Updates the peer’s last_seen timestamp.
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> UnsafeUnpin 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
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>
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>
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