libp2p / js-libp2p-webrtc-star

libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star
https://libp2p.io
Other
319 stars 95 forks source link

Discovery discovers self #171

Closed kumavis closed 4 years ago

kumavis commented 5 years ago

"libp2p-webrtc-star": "^0.15.8"

sometimes accidently discovers self

  // connect to all discovered nodes
  node.on('peer:discovery', (peer) => {
    // this happens i guess
    if (clientId === peer.id.toB58String()) return
    // ignore failures
    node.dial(peer, (err) => {})
  })

node config

 const wstar = new WStar()
  const node = new Libp2p({
    peerInfo,
    modules: {
      transport: [
        WS,
        wstar
      ],
      streamMuxer: [
        Mplex
      ],
      peerDiscovery: [
        wstar.discovery,
      ],
      dht: DHT,
    },
    config: {
      peerDiscovery: {
      },
      dht: {
        enabled: true,
        kBucketSize: 20,
      },
    }
  })
jacobheun commented 5 years ago

Since transports don't always have access to their own PeerInfo instance (which we should probably correct by always passing the libp2p node in transport options), detecting itself on peer discovery is not reasonably possible. We should make the change at https://github.com/libp2p/js-libp2p/issues/356 to avoid downstream users from getting the event.

jacobheun commented 4 years ago

This has been resolved in js-libp2p