Skip to content

libp2p events #1574

@achingbrain

Description

@achingbrain

The libp2p object returned from createLibp2p is an EventTarget that emits a few different events.

These events are really useful for observing the inner workings of libp2p without having to tie your code to the internal structure of libp2p.

They also open the door to real-time monitoring of libp2p with better observability and debugging possibilities.

The event list should be expanded to encompass more events. Some (non-exhausive) suggestions:

  • peer:dial - when we dial a peer, the event should hold the peer id and which multiaddrs are being dialled
  • peer:dial:success - the event should hold the peer id and the multiaddr that succeeded
  • peer:dial:error - the event should hold the peer id and the multiaddr that failed and an Error object
  • identify:success - the identify protocol competed for a peer - the event should hold the peer id
  • identify:error - the identify protocol failed for a peer - the event should hold the peer id and an Error object
  • identify:push:success - the identify push protocol competed for a peer - the event should hold the peer id
  • identify:push:error - the identify push protocol failed for a peer - the event should hold the peer id and an Error object
  • connection:prune - we pruned a connection, the event should have the peer id of the connection that was closed
  • connection:upgrade - a connection was upgraded, the event should have the connection that was upgraded
  • ...other things?

It would be good to establish a naming convention for events, the above hasn't had a whole lot of thought applied to it.

Metadata

Metadata

Assignees

Labels

P2Medium: Good to have, but can wait until someone steps upexplorationkind/enhancementA net-new feature or improvement to an existing featureneed/analysisNeeds further analysis before proceeding

Type

No type

Projects

Status

🎉Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions