js-libp2p-gossipsub
js-libp2p-gossipsub copied to clipboard
feat: Dispatch event on IHAVE received
This PR adds a dispatching event when the node receives an IHAVE message from a peer.
This feature is useful in scenarios where, for any reason, the received message (or rather, the data message transmitted) gets lost in the future, and we need to query the peer to fetch this data using a Request/Response style protocol.
Knowing which peers had this message/data in the first place makes these queries more intelligent/targeted.
Specific example:
- Peers gossip transactions
- Some transaction is added to the local
mempool - time passes and the transaction gets evicted for whatever reason
- time passes and now we need this specific tx (be it for block building, proving, serving RPC request, etc.). We have to fetch it from a peer.
- It would be best to query peers that we know have had this transaction at some point because they've sent us an
IHAVEmessage.