Responsible for managing known connections.
Proactively tries to connect to known peers stored in the PeerStore. It will keep the number of connections below the upper limit and sort the peers to connect based on wether we know their keys and protocols.
If the value
of name
has exceeded its limit, maybe close a connection
Checks the libp2p metrics to determine if any values have exceeded the configured maximums.
If we have more connections than our maximum, close a connection to the lowest valued peer.
If the event loop is slow, maybe close a connection
Map of peer identifiers to their peer value for pruning connections.
Map of connections per peer
Get current number of open connections.
Cleans up the connections
Get a connection with a peer.
Get all open connections with a peer.
Tracks the incoming connection and check the connection limit
Removes the connection from tracking
Sets the value of the given peer. Peers with lower values will be disconnected first.
A number between 0 and 1
Starts the Connection Manager. If Metrics are not enabled on libp2p only event loop and connection limits will be monitored.
Stops the Connection Manager
ConnectionManager#peer:connect Emitted when a new peer is connected.
ConnectionManager#peer:disconnect Emitted when a peer is disconnected.