-
Notifications
You must be signed in to change notification settings - Fork 501
Description
Throughout the libp2p modules, especially when peer discovery is involved, modules will often do some combination of adding the peer to the PeerBook
and/or emitting the peer
event for discovery.
I'd like to suggest we change the behavior to emit only, and have libp2p process the necessary modifications to the PeerBook. The reason for this, is that by centralizing the decision to update the PeerBook, libp2p will have a clearer understanding of what peers are actually new, versus those that were already discovered. In turn, it can emit the peer discovery event to listening application code.
Currently, libp2p has to emit everything, because the underlying modules may have already added the peer to the PeerBook, which causes a lot of duplicate peer discovery events.
Reference libp2p/js-libp2p-kad-dht#93 (comment)