[core/swarm] Refactor and extend configurable connection limits. (#1848)

* Refactor and extend configurable connection limits.

To better track different connection counts, permit configurable
limits for these counts and make these available for
inspection efficiently, introduce dedicated connection counters
via a `ConnectionCounters` structure that is exposed on the
API via the `NetworkInfo`. All connection or connection
states that are counted in this way can also have effective
configurable limits.

* Cleanup

* Add missing file.

* Refine naming and config API.

* Update core/CHANGELOG.md

Co-authored-by: Max Inden <mail@max-inden.de>

* Update core/CHANGELOG.md

Co-authored-by: Max Inden <mail@max-inden.de>

Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
Roman Borschel
2020-11-23 17:22:15 +01:00
committed by GitHub
parent 1bd013c843
commit cef75ab7e1
10 changed files with 501 additions and 270 deletions

View File

@ -32,6 +32,7 @@ pub use listeners::{ListenerId, ListenersStream, ListenersEvent};
pub use manager::ConnectionId;
pub use substream::{Substream, SubstreamEndpoint, Close};
pub use pool::{EstablishedConnection, EstablishedConnectionIter, PendingConnection};
pub use pool::{ConnectionLimits, ConnectionCounters};
use crate::muxing::StreamMuxer;
use crate::{Multiaddr, PeerId};
@ -326,9 +327,9 @@ impl<'a> OutgoingInfo<'a> {
#[derive(Debug, Clone)]
pub struct ConnectionLimit {
/// The maximum number of connections.
pub limit: usize,
pub limit: u32,
/// The current number of connections.
pub current: usize,
pub current: u32,
}
impl fmt::Display for ConnectionLimit {