Closed
Description
Type: Feature
Severity: N/A
Description:
There are use cases where we want to leverage libp2p to dial other peers using a specific protocol, but fallback to another one if that peer does not support the initial attempt. With the current API we need to do a cascade of dials, in order to do this, while libp2p could offer this in its API.
One example of this is in the Gossipsub implementation ChainSafe/gossipsub-js#34, where we intend to fallback to floodsubs if the peer does not support gossipsub.
We should have a utility to handle multi protocol negotiation, receiving a list of protocols and trying to dial by its order. An example could be:
const protocolPreferences = [gossipsubMulticodec, floodsubMulticodec]
libp2p.newStream(peerInfo, protocolPreferences, callback)
// or
libp2p.dialBest(peerInfo, protocolPreferences, callback)
This was discussed with @jacobheun in the Gossipsub PR
Metadata
Metadata
Assignees
Labels
No labels