Skip to content

swarm/: Support generic connection management #2824

Closed
@mxinden

Description

Description

Today a user can:

  1. Set a limit for incoming/outgoing/pending connections, global and per peer.
  2. Close a connection via NetworkBehaviour.
  3. 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 PeerId or 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:

  1. Make the pool::ConnectionCounter generic 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 NetworkBehaviour trait and thus limited in its decision making.
  2. Extend NetworkBehaviour with 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.
  3. Emit a SwarmEvent::ReviewConnection requiring 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.

Are you planning to do it yourself in a pull request?

Yes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions