Struct lumina_node::peer_tracker::PeerTracker
source · pub struct PeerTracker { /* private fields */ }Expand description
Keeps track various information about peers.
Implementations§
source§impl PeerTracker
impl PeerTracker
sourcepub fn info(&self) -> PeerTrackerInfo
pub fn info(&self) -> PeerTrackerInfo
Returns the current PeerTrackerInfo.
sourcepub fn info_watcher(&self) -> Receiver<PeerTrackerInfo>
pub fn info_watcher(&self) -> Receiver<PeerTrackerInfo>
Returns a watcher for any PeerTrackerInfo changes.
sourcepub fn set_maybe_discovered(&self, peer: PeerId) -> bool
pub fn set_maybe_discovered(&self, peer: PeerId) -> bool
Sets peer as discovered if this is it’s first appearance.
Returns true if peer was not known from before.
sourcepub fn add_addresses<I, A>(&self, peer: PeerId, addrs: I)where
I: IntoIterator<Item = A>,
A: Borrow<Multiaddr>,
pub fn add_addresses<I, A>(&self, peer: PeerId, addrs: I)where
I: IntoIterator<Item = A>,
A: Borrow<Multiaddr>,
Add an address for a peer.
sourcepub fn set_trusted(&self, peer: PeerId, is_trusted: bool)
pub fn set_trusted(&self, peer: PeerId, is_trusted: bool)
Sets peer as trusted.
sourcepub fn set_connected(
&self,
peer: PeerId,
connection_id: ConnectionId,
address: impl Into<Option<Multiaddr>>
)
pub fn set_connected( &self, peer: PeerId, connection_id: ConnectionId, address: impl Into<Option<Multiaddr>> )
Sets peer as connected.
sourcepub fn set_maybe_disconnected(
&self,
peer: PeerId,
connection_id: ConnectionId
) -> bool
pub fn set_maybe_disconnected( &self, peer: PeerId, connection_id: ConnectionId ) -> bool
Sets peer as disconnected if connection_id was the last connection.
Returns true if was set to disconnected.
sourcepub fn set_identified(&self, peer: PeerId, info: &Info)
pub fn set_identified(&self, peer: PeerId, info: &Info)
Sets peer as identified.
sourcepub fn is_connected(&self, peer: PeerId) -> bool
pub fn is_connected(&self, peer: PeerId) -> bool
Returns true if peer is connected.
sourcepub fn addresses(&self, peer: PeerId) -> SmallVec<[Multiaddr; 4]>
pub fn addresses(&self, peer: PeerId) -> SmallVec<[Multiaddr; 4]>
Returns the addresses of the peer.
sourcepub fn connected_peers(&self) -> Vec<PeerId>
pub fn connected_peers(&self) -> Vec<PeerId>
Returns connected peers.
sourcepub fn best_n_peers(&self, limit: usize) -> Vec<PeerId>
pub fn best_n_peers(&self, limit: usize) -> Vec<PeerId>
Returns up to N amount of best peers.
sourcepub fn trusted_n_peers(&self, limit: usize) -> Vec<PeerId>
pub fn trusted_n_peers(&self, limit: usize) -> Vec<PeerId>
Returns up to N amount of trusted peers.
Trait Implementations§
source§impl Debug for PeerTracker
impl Debug for PeerTracker
Auto Trait Implementations§
impl !RefUnwindSafe for PeerTracker
impl Send for PeerTracker
impl Sync for PeerTracker
impl Unpin for PeerTracker
impl !UnwindSafe for PeerTracker
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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