pub struct ConnectionManager { /* private fields */ }Expand description
Connection manager
Implementations§
Source§impl ConnectionManager
impl ConnectionManager
Sourcepub fn new(config: ConnectionLimitsConfig) -> Self
pub fn new(config: ConnectionLimitsConfig) -> Self
Create a new connection manager
Sourcepub fn should_accept(
&self,
peer_id: &PeerId,
direction: ConnectionDirection,
) -> bool
pub fn should_accept( &self, peer_id: &PeerId, direction: ConnectionDirection, ) -> bool
Check if a new connection should be accepted
Sourcepub fn connection_established(
&self,
peer_id: PeerId,
direction: ConnectionDirection,
)
pub fn connection_established( &self, peer_id: PeerId, direction: ConnectionDirection, )
Register a new connection
Sourcepub fn connection_closed(&self, peer_id: &PeerId)
pub fn connection_closed(&self, peer_id: &PeerId)
Unregister a connection
Sourcepub fn record_activity(&self, peer_id: &PeerId, sent: bool)
pub fn record_activity(&self, peer_id: &PeerId, sent: bool)
Record activity on a connection
Sourcepub fn update_score(&self, peer_id: &PeerId, delta: i16)
pub fn update_score(&self, peer_id: &PeerId, delta: i16)
Update connection score
Sourcepub fn update_latency(&self, peer_id: &PeerId, latency_ms: u64)
pub fn update_latency(&self, peer_id: &PeerId, latency_ms: u64)
Update connection latency
Sourcepub fn add_reserved(&self, peer_id: PeerId)
pub fn add_reserved(&self, peer_id: PeerId)
Add a peer to reserved list
Sourcepub fn remove_reserved(&self, peer_id: &PeerId)
pub fn remove_reserved(&self, peer_id: &PeerId)
Remove a peer from reserved list
Sourcepub fn unban_peer(&self, peer_id: &PeerId)
pub fn unban_peer(&self, peer_id: &PeerId)
Unban a peer
Sourcepub fn get_prune_candidates(&self, count: usize) -> Vec<PeerId>
pub fn get_prune_candidates(&self, count: usize) -> Vec<PeerId>
Get peers that should be disconnected (pruning candidates)
Sourcepub fn get_idle_connections(&self) -> Vec<PeerId>
pub fn get_idle_connections(&self) -> Vec<PeerId>
Get idle connections that should be closed
Sourcepub fn prune_to_limit(&self) -> Vec<PeerId>
pub fn prune_to_limit(&self) -> Vec<PeerId>
Prune connections to make room for new ones
Returns peer IDs that should be disconnected
Sourcepub fn connected_peers(&self) -> Vec<PeerId>
pub fn connected_peers(&self) -> Vec<PeerId>
Get all connected peer IDs
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get connection count
Sourcepub fn is_connected(&self, peer_id: &PeerId) -> bool
pub fn is_connected(&self, peer_id: &PeerId) -> bool
Check if connected to a peer
Sourcepub fn stats(&self) -> ConnectionManagerStats
pub fn stats(&self) -> ConnectionManagerStats
Get connection statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConnectionManager
impl !RefUnwindSafe for ConnectionManager
impl Send for ConnectionManager
impl Sync for ConnectionManager
impl Unpin for ConnectionManager
impl UnwindSafe for ConnectionManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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