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).
Last updated 6 years ago by vascosantos .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install libp2p-floodsub 
SYNC missed versions from official npm registry.

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(peerId, registrar, options)

await fsub.start()

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

fsub.publish('fruit', new TextEncoder().encode('banana'))

API

Create a floodsub implementation

const options = {…}
const floodsub = new Floodsub(peerId, 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 Uint8Array 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', (peerId, topics, changes) => { ... })
  • peerId: a PeerId 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.

Current Tags

  • 0.29.1                                ...           latest (3 years ago)

69 Versions

  • 0.29.1                                ...           3 years ago
  • 0.29.0                                ...           3 years ago
  • 0.28.0                                ...           3 years ago
  • 0.27.1                                ...           3 years ago
  • 0.27.0                                ...           3 years ago
  • 0.26.0                                ...           4 years ago
  • 0.25.3                                ...           4 years ago
  • 0.25.2                                ...           4 years ago
  • 0.25.1                                ...           4 years ago
  • 0.25.0                                ...           4 years ago
  • 0.24.1                                ...           4 years ago
  • 0.24.0                                ...           4 years ago
  • 0.23.1                                ...           4 years ago
  • 0.23.0                                ...           4 years ago
  • 0.22.0                                ...           4 years ago
  • 0.21.3                                ...           5 years ago
  • 0.20.4                                ...           5 years ago
  • 0.21.2                                ...           5 years ago
  • 0.20.3                                ...           5 years ago
  • 0.21.1                                ...           5 years ago
  • 0.21.0                                ...           5 years ago
  • 0.20.2                                ...           5 years ago
  • 0.20.1                                ...           5 years ago
  • 0.20.0                                ...           5 years ago
  • 0.19.0                                ...           5 years ago
  • 0.18.0                                ...           5 years ago
  • 0.17.2                                ...           5 years ago
  • 0.17.1                                ...           5 years ago
  • 0.17.0                                ...           5 years ago
  • 0.16.1                                ...           6 years ago
  • 0.16.0                                ...           6 years ago
  • 0.15.8                                ...           6 years ago
  • 0.15.7                                ...           6 years ago
  • 0.15.6                                ...           6 years ago
  • 0.15.5                                ...           6 years ago
  • 0.15.4                                ...           6 years ago
  • 0.15.3                                ...           6 years ago
  • 0.15.2                                ...           6 years ago
  • 0.15.1                                ...           6 years ago
  • 0.15.0                                ...           7 years ago
  • 0.14.1                                ...           7 years ago
  • 0.14.0                                ...           7 years ago
  • 0.13.1                                ...           7 years ago
  • 0.13.0                                ...           7 years ago
  • 0.12.1                                ...           7 years ago
  • 0.12.0 [deprecated]           ...           7 years ago
  • 0.11.1                                ...           7 years ago
  • 0.11.0                                ...           7 years ago
  • 0.10.1                                ...           7 years ago
  • 0.10.0                                ...           7 years ago
  • 0.9.4                                ...           8 years ago
  • 0.9.3                                ...           8 years ago
  • 0.9.2                                ...           8 years ago
  • 0.9.1                                ...           8 years ago
  • 0.9.0                                ...           8 years ago
  • 0.8.1                                ...           8 years ago
  • 0.8.0                                ...           8 years ago
  • 0.7.5                                ...           8 years ago
  • 0.7.4                                ...           8 years ago
  • 0.7.3                                ...           8 years ago
  • 0.7.2                                ...           8 years ago
  • 0.7.1                                ...           8 years ago
  • 0.7.0                                ...           8 years ago
  • 0.6.0                                ...           8 years ago
  • 0.5.0                                ...           8 years ago
  • 0.4.1                                ...           8 years ago
  • 0.4.0                                ...           8 years ago
  • 0.3.1                                ...           8 years ago
  • 0.3.0                                ...           8 years ago
Downloads
Total 2
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (9)
Dev Dependencies (11)

© 2010 - cnpmjs.org x YWFE | Home | YWFE