Skip to content

ConnectionManager events #675

Closed
Closed
@vasco-santos

Description

@vasco-santos

Creating this per discussion on ChainSafe/js-libp2p-gossipsub#87 (comment)

There are currently a few inconsistencies with the ConnectionManager events that need to be solved:

it seems that there are some problems with our current approach of updating IPs, and it seems the events currently emitted by the connection manager are not sufficient for tracking IPs to open connections for peers with scores.
issue 1: ConnectionManager doesn't emit on closed connections. ConnectionManager#_maybeDisconnectOne, doesn't emit when a connection is closed, more generally, ConnectionManager isn't tracking/emitting on manually closed connections, but rather only on calls to ConnectionManager#onDisconnect.
issue 2: ConnectionManager emits peer:connect event before storing the emitted connection.
The current approach is to use ConnectionManager#getAll on each peer:connect event for a list of current IPs, but since the event is triggered before the new connection is stored, the call to getAll will not include the new connection unless the event handler awaits the ConnectionManager#onConnect finishing in its entirety. But that potentially also runs into issues re issue 1.

cc @wemeetagain

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: Likely tackled by core team if no one steps upexp/noviceSomeone with a little familiarity can pick upkind/bugA bug in existing code (including security flaws)status/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions