js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

Implementation assumes tranpsorts inclue a discover

Open Gozala opened this issue 4 years ago • 1 comments

As per https://github.com/libp2p/js-libp2p/pull/802/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R648 implementation makes assumption that Transport includes a discovery but that assumption is not supported by the interface definition.

We should either iterate on an interface or an implementation so that assumptions made by the implementation are supported by the defined interface.

Gozala avatar Dec 09 '20 23:12 Gozala

Regarding this, this will probably get into libp2p configuration improvements effort. This is not really interface related issue as the Transport Interface should not need to know about any discovery.

This is currently a hack that enables us to do:

const WebrtcStar = require('libp2p-webrtc-star')

const libp2p = await Libp2p.create({
  modules: {
    transport: [WebrtcStar]
  }
})

Enabling its built in discovery. Webrtc-star is the only transport using this transport.discovery.

It should really go into discovery

const WebrtcStar = require('libp2p-webrtc-star')

const libp2p = await Libp2p.create({
  modules: {
    transport: [WebrtcStar],
    peerDiscovery: [WebrtcStar]
  }
})

But this currently is not possible, as we would need to construct WebrtcStar before, which requires libp2p's upgrader.

vasco-santos avatar Dec 10 '20 08:12 vasco-santos

Closing due to staleness

maschad avatar Sep 28 '23 19:09 maschad