How to use the libp2p-interfaces/src/connection.Connection.isConnection function in libp2p-interfaces

To help you get started, we’ve selected a few libp2p-interfaces examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / js-libp2p / src / registrar.js View on Github external
onConnect (peerInfo, conn) {
    assert(PeerInfo.isPeerInfo(peerInfo), 'peerInfo must be an instance of peer-info')
    assert(Connection.isConnection(conn), 'conn must be an instance of interface-connection')

    const id = peerInfo.id.toB58String()
    const storedConn = this.connections.get(id)

    if (storedConn) {
      storedConn.push(conn)
    } else {
      this.connections.set(id, [conn])
    }
  }