-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Description
Today a user can:
- Set a limit for incoming/outgoing/pending connections, global and per peer.
- Close a connection via
NetworkBehaviour.- Keep a connection alive via
ConnectionHandler::keep_alive.A user is restricted in (1) as they can not do anything beyond setting upper bound limits. E.g. they can not decide whether to accept or deny an incoming connection based on the IP, the
PeerIdor on their current CPU or memory utilization.
(Taken from #2118 (comment).)
I see 3 ways how we can enable users to do advanced connection management:
- Make the
pool::ConnectionCountergeneric and allow users to provide their own.- Yet another moving piece.
- When not
Boxed requires an additional generic parameter. - Can only do connection management. Not as powerful as the
NetworkBehaviourtrait and thus limited in its decision making.
- Extend
NetworkBehaviourwith methods called to review a pending or established connection.- Yet another set of methods on
NetworkBehaviour. - Has knowledge of the full state, thus allows powerful decision making.
- Users are already familiar with it.
- Yet another set of methods on
- Emit a
SwarmEvent::ReviewConnectionrequiring the user to manually accept each pending/established connection via e.g.Swarm::accept().- Complicates the getting-started experience. User has to explicitly call a method to make progress. Not intuitive.
Motivation
Allows downstream users to do advanced connection management and can simplify existing implementations working around this today.
- https://github.com/sigp/lighthouse/tree/stable/beacon_node/lighthouse_network/src/peer_manager
- https://github.com/paritytech/substrate/blob/master/client/peerset/src/lib.rs
- https://github.com/n0-computer/iroh/tree/main/iroh-p2p
Are you planning to do it yourself in a pull request?
Yes
dignifiedquire, elenaf9 and dariusc93
Metadata
Metadata
Assignees
Labels
No labels