Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libp2p-floodsub

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p-floodsub

libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).

  • 0.20.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by68.88%
Maintainers
2
Weekly downloads
 
Created
Source

js-libp2p-floodsub

Discourse posts Coverage Status Travis CI Circle CI Dependency Status js-standard-style

libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).

Lead Maintainer

Vasco Santos.

Table of Contents

Install

> npm install libp2p-floodsub

Usage

const FloodSub = require('libp2p-floodsub')

// registrar is provided by libp2p
const fsub = new FloodSub(peerInfo, registrar, options)

await fsub.start()

fsub.on('fruit', (data) => {
  console.log(data)
})
fsub.subscribe('fruit')

fsub.publish('fruit', new Buffer('banana'))

API

Create a floodsub implementation

const options = {…}
const floodsub = new Floodsub(peerInfo, registrar, options)

Options is an optional object with the following key-value pairs:

  • emitSelf: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to false).

For the remaining API, see https://github.com/libp2p/js-libp2p-pubsub

Events

Floodsub emits two kinds of events:

  1. <topic> when a message is received for a particular topic
  fsub.on('fruit', (data) => { ... })
  • data: a Buffer containing the data that was published to the topic
  1. floodsub:subscription-change when the local peer receives an update to the subscriptions of a remote peer.
  fsub.on('floodsub:subscription-change', (peerInfo, topics, changes) => { ... })
  • peerInfo: a PeerInfo object
  • topics: the topics that the peer is now subscribed to
  • changes: an array of { topicID: <topic>, subscribe: <boolean> } eg [ { topicID: 'fruit', subscribe: true }, { topicID: 'vegetables': false } ]

Contribute

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

This repository falls under the IPFS Code of Conduct.

License

Copyright (c) Protocol Labs, Inc. under the MIT License. See LICENSE file for details.

Keywords

FAQs

Package last updated on 14 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc