0.29.1 • Published 2 years ago

libp2p-floodsub v0.29.1

Weekly downloads
5,968
License
Apache-2.0 OR MIT
Repository
github
Last release
2 years ago

js-libp2p-floodsub

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

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.

0.29.0

2 years ago

0.29.1

2 years ago

0.28.0

2 years ago

0.27.1

3 years ago

0.27.0

3 years ago

0.25.3

3 years ago

0.25.2

3 years ago

0.26.0

3 years ago

0.25.1

3 years ago

0.25.0

3 years ago

0.24.1

3 years ago

0.24.0

3 years ago

0.23.1

4 years ago

0.23.0

4 years ago

0.22.0

4 years ago

0.21.3

4 years ago

0.20.4

4 years ago

0.21.2

4 years ago

0.21.1

4 years ago

0.21.0

4 years ago

0.20.3

4 years ago

0.20.2

4 years ago

0.20.1

4 years ago

0.20.0

4 years ago

0.19.0

4 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

5 years ago

0.16.0

5 years ago

0.15.8

5 years ago

0.15.7

5 years ago

0.15.6

5 years ago

0.15.5

5 years ago

0.15.4

5 years ago

0.15.3

5 years ago

0.15.2

5 years ago

0.15.1

5 years ago

0.15.0

6 years ago

0.14.1

6 years ago

0.14.0

6 years ago

0.13.1

6 years ago

0.13.0

6 years ago

0.12.1

6 years ago

0.12.0

6 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

7 years ago

0.9.3

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

8 years ago