How to use the mafmt.P2P function in mafmt

To help you get started, we’ve selected a few mafmt 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-bootstrap / src / index.js View on Github external
this._list.forEach(async (candidate) => {
      if (!mafmt.P2P.matches(candidate)) {
        return log.error('Invalid multiaddr')
      }

      const ma = multiaddr(candidate)

      const peerId = PeerId.createFromB58String(ma.getPeerId())

      try {
        const peerInfo = await PeerInfo.create(peerId)
        peerInfo.multiaddrs.add(ma)
        this.emit('peer', peerInfo)
      } catch (err) {
        log.error('Invalid bootstrap peer id', err)
      }
    })
  }

mafmt

A multiaddr validator

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis