Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

⛔️ DEPRECATED: peer-info is not used anymore in favour of storing this data in the PeerStore from libp2p@0.28.0.


Discourse posts Dependency Status js-standard-style

Lead Maintainer

Vasco Santos

Table of Contents



> npm i peer-info

Node.JS, Browserify, Webpack

const PeerInfo = require('peer-info')

Browser: <script> Tag

Loading this module through a script tag will make the PeerInfo obj available in the global namespace.

<script src=""></script>
<!-- OR -->
<script src=""></script>


const PeerInfo = require('peer-info')
const peer = new PeerInfo()

// TCP port 5001

// UDP port 8001

// mic/speaker soundwaves using frequencies 697 and 1209


const PeerInfo = require('peer-info')


Creates a new PeerInfo instance and if no id is passed it generates a new underlying PeerID for it.

Returns Promise<PeerInfo>.

new PeerInfo(id)

  • id: PeerId - instance of PeerId (optional)

Creates a new PeerInfo instance from an existing PeerId.


The PeerId of the peer this info relates to.


A list of protocols that peer supports.


Adds a protocol that peer can support. protocol is a string.


Removes a protocol that peer no longer supports. protocol is a string.


A list of multiaddresses instances that peer can be reached at.


  • addr: Multiaddr

Adds a new multiaddress that peer can be reached at. addr is an instance of a multiaddr.


  • addr: Multiaddr

The addSafe call, in comparison to add, will only add the multiaddr to multiaddrs if the same multiaddr tries to be added twice.

This is a simple mechanism to prevent multiaddrs from becoming bloated with unusable addresses, which happens when we exchange observed multiaddrs with peers which will not provide a useful multiaddr to be shared to the rest of the network (e.g. a multiaddr referring to a peer inside a LAN being shared to the outside world).


  • addr: Multiaddr

Removes a multiaddress instance addr from peer.

.multiaddrs.replace(existing, fresh)

  • existing: Multiaddr
  • fresh: Multiaddr

Removes the array of multiaddresses existing from peer, and adds the array of multiaddresses fresh.


Records the given multiaddr, ma as the active multiaddr of the peer.

  • ma: Multiaddr


Removes the existing connected Multiaddr from tracking.


Returns true if a connected Multiaddr exists, otherwise returns false.


PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.


MIT © David Dias

You can’t perform that action at this time.