feat: introduce libp2p-connection-limits connection management module

This patch deprecates the existing connection limits within `Swarm` and uses the new `NetworkBehaviour` APIs to implement it as a plugin instead.

Related #2824.

Pull-Request: #3386.
This commit is contained in:
Thomas Eizinger
2023-03-21 16:04:53 +01:00
committed by GitHub
parent 0341817b26
commit 48a70e5102
17 changed files with 643 additions and 18 deletions

View File

@ -377,6 +377,7 @@ impl<'a> IncomingInfo<'a> {
}
/// Information about a connection limit.
#[deprecated(note = "Use `libp2p::connection_limits` instead.", since = "0.42.1")]
#[derive(Debug, Clone, Copy)]
pub struct ConnectionLimit {
/// The maximum number of connections.
@ -385,6 +386,7 @@ pub struct ConnectionLimit {
pub current: u32,
}
#[allow(deprecated)]
impl fmt::Display for ConnectionLimit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
@ -396,6 +398,7 @@ impl fmt::Display for ConnectionLimit {
}
/// A `ConnectionLimit` can represent an error if it has been exceeded.
#[allow(deprecated)]
impl std::error::Error for ConnectionLimit {}
struct SubstreamUpgrade<UserData, Upgrade> {