npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

libp2p-pubsub-peer-discovery

v4.0.0

Published

A libp2p module that uses pubsub for mdns like peer discovery

Readme

js-libp2p Pubsub Peer Discovery

A js-libp2p module that uses pubsub for interval broadcast peer discovery

Lead Maintainer

Jacob Heun.

Design

Flow

  • When the discovery module is started by libp2p it subscribes to the discovery pubsub topic(s)
  • It will immediately broadcast your peer data via pubsub and repeat the broadcast on the configured interval

Security Considerations

It is worth noting that this module does not include any message signing for broadcasts. The reason for this is that libp2p-pubsub supports message signing and enables it by default, which means the message you received has been verified to be from the originator, so we can trust that the peer information we have received is indeed from the peer who owns it. This doesn't mean the peer can't falsify its own records, but this module isn't currently concerned with that scenario.

Usage

Requirements

This module MUST be used on a libp2p node that is running Pubsub. If Pubsub does not exist, or is not running, this module will not work.

Usage in js-libp2p

See the js-libp2p configuration docs for how to include this module as a peer discovery module in js-libp2p.

If you are only interested in listening to the global pubsub topic the minimal configuration for using this with libp2p is:

const Libp2p = require('libp2p')
const Websockets = require('libp2p-websockets')
const MPLEX = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const GossipSub = require('libp2p-gossipsub')
const PubsubPeerDiscovery = require('libp2p-pubsub-peer-discovery')

const node = await Libp2p.create({
  modules: {
    transport: [Websockets], // Any libp2p transport(s) can be used
    streamMuxer: [MPLEX],
    connEncryption: [NOISE],
    pubsub: GossipSub, // Can also be `libp2p-floodsub` if desired
    peerDiscovery: [PubsubPeerDiscovery]
  }
})

Customizing Pubsub Peer Discovery

There are a few options you can use to customize Pubsub Peer Discovery. You can see the detailed options below.

// ... Other imports from above
const PubsubPeerDiscovery = require('libp2p-pubsub-peer-discovery')

// Custom topics
const topics = [
  `myApp._peer-discovery._p2p._pubsub`, // It's recommended but not required to extend the global space
  '_peer-discovery._p2p._pubsub' // Include if you want to participate in the global space
]

const node = await Libp2p.create({
  modules: { /* See 'Usage in js-libp2p' for this block */ },
  config: {
    peerDiscovery: {
      'PubsubPeerDiscovery': { // 'PubsubPeerDiscovery' is also available from the static property PubsubPeerDiscovery.tag
        interval: 10000,
        topics: topics, // defaults to ['_peer-discovery._p2p._pubsub']
        listenOnly: false
      }
    }
  }
})

Options

| Name | Type | Description | |------|------|-------------| | interval | number | How often (in ms), after initial broadcast, your node should broadcast your peer data. Default (10000ms)| | topics | Array<string> | An Array of topic strings. If set, the default topic will not be used and must be included explicitly here | | listenOnly | boolean | If true it will not broadcast peer data. Dont set this unless you have a specific reason to. Default (false) |

Default Topic

The default pubsub topic the module subscribes to is _peer-discovery._p2p._pubsub, which is also set on PubsubPeerDiscovery.TOPIC.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT - Protocol Labs 2020