Détail du package

libp2p-floodsub

libp2p8.6kApache-2.0 OR MIT0.29.1

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).

IPFS, flood, flooding, gossip

readme

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
  2. 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.

changelog

0.29.1 (2022-02-18)

Trivial Changes

0.29.0 (2021-12-31)

Features

BREAKING CHANGES

  • peerstore methods are now all async

0.28.0 (2021-12-02)

chore

BREAKING CHANGES

  • requires node 15+

0.27.1 (2021-08-19)

0.27.0 (2021-07-09)

chore

BREAKING CHANGES

  • uses new multiaddr, libp2p-interfaces, etc

0.26.0 (2021-05-28)

0.25.3 (2021-05-28)

Reverts

  • Revert "chore: update pubsub interface to run subsystem tests (#113)" (7bd6e20), closes #113

0.25.2 (2021-05-28)

0.25.1 (2021-04-15)

0.25.0 (2021-04-13)

0.24.1 (2020-12-16)

0.24.0 (2020-11-13)

chore

BREAKING CHANGES

  • signing policy added instead of strictsigning options

0.23.1 (2020-09-04)

0.23.0 (2020-08-25)

Bug Fixes

  • replace node buffers with uint8arrays (5a522b4)

Chores

BREAKING CHANGES

  • using libp2p-interface pubsub with new API
    • The .data property of received pubsub messages was a Buffer, now it is a Uint8Array
  • All deps of this module use Uint8Arrays

0.22.0 (2020-08-11)

Bug Fixes

  • replace node buffers with uint8arrays (5a522b4)

BREAKING CHANGES

    • The .data property of received pubsub messages was a Buffer, now it is a Uint8Array
  • All deps of this module use Uint8Arrays

0.21.3 (2020-06-04)

Bug Fixes

0.21.2 (2020-05-04)

0.21.1 (2020-04-23)

Bug Fixes

0.21.0 (2020-04-23)

Chores

BREAKING CHANGES

  • using new topology api with peer-id instead of peer-info and new pubsub internal peer data structure

0.20.2 (2020-02-14)

Bug Fixes

0.20.1 (2020-02-06)

0.20.0 (2019-12-02)

Chores

BREAKING CHANGES

  • getPeersSubscribed from parent class renamed to getSubscribers to remove redundant wordin

0.19.0 (2019-11-14)

Code Refactoring

BREAKING CHANGES

  • Switch to using async/await and async iterators.

0.18.0 (2019-09-06)

Features

BREAKING CHANGES

  • messages are not self emitted by default anymore. You need to set the emitSelf option to true to use it

0.17.2 (2019-09-03)

Features

  • pass options to base protocol constructor (#87) (daa97f8)

0.17.1 (2019-07-25)

Features

0.17.0 (2019-07-08)

Features

  • add strict signing validation for messages (#84 (eed2bc5)

BREAKING CHANGES

  • If messages are not being signed, this change will result in them being dropped. A previous release of floodsub added signing by default, but any Floodsub version older than v0.16.0 will have their messages dropped. This is inline with the latest go pubsub behavior.

0.16.1 (2019-05-08)

Bug Fixes

  • _emitMessages should not emit normalized messages (#79) (917b7f1)

0.16.0 (2019-05-07)

Bug Fixes

Features

BREAKING CHANGES

  • publish now takes a callback as it needs to sign messages

0.15.8 (2019-02-14)

0.15.7 (2019-01-09)

Bug Fixes

0.15.6 (2019-01-04)

0.15.5 (2018-12-15)

Bug Fixes

  • crash when disconnect happens during dial (#65) (894e3cc)

0.15.4 (2018-12-15)

Bug Fixes

0.15.3 (2018-12-06)

Bug Fixes

  • prevent double dialing same peer (#63) (3303ad0)

0.15.2 (2018-11-28)

Features

  • emit event when a remote peer's subscriptions change (#61) (7611b2e)

0.15.1 (2018-10-23)

Bug Fixes

Features

0.15.0 (2018-04-05)

0.14.1 (2018-02-12)

0.14.0 (2018-02-10)

Features

0.13.1 (2017-12-05)

Bug Fixes

  • remove peer once the peer closes. should fix peer leak (#52) (6e6c507)

0.13.0 (2017-11-22)

Bug Fixes

0.12.1 (2017-11-20)

0.12.0 (2017-11-16)

Bug Fixes

0.11.1 (2017-09-07)

Features

  • replace protocol-buffers with protons (#48) (d5b7e23)

0.11.0 (2017-07-23)

0.10.1 (2017-07-21)

Features

  • update deps and stop using swarm directly (281771e)

0.10.0 (2017-07-07)

Bug Fixes

  • _dialPeer always calls back (bccffd6)
  • no more dep on ipfs-nodejs (551fc4c)

0.9.4 (2017-05-16)

Bug Fixes

  • avoid race condition on unsubscribe (8cf5498)

0.9.3 (2017-05-12)

Bug Fixes

  • check if peer exists first (6b18a4f)

0.9.2 (2017-05-12)

Bug Fixes

  • race condition (8dd9f3b)
  • really nasty race condition that would only happen on travis while running js-ipfs tests (09220b9)

0.9.1 (2017-05-04)

Bug Fixes

  • use async setImmediate, make browserify happy (9ec264b)

0.9.0 (2017-04-03)

Features

0.8.1 (2017-03-29)

0.8.0 (2017-03-27)

Features

  • update to latest libp2p-api (798c2ae)

0.7.5 (2017-03-21)

0.7.4 (2017-02-20)

0.7.3 (2017-02-09)

Features

  • change window to self for webworker support (61d396f)

0.7.2 (2017-01-29)

0.7.1 (2017-01-11)

Bug Fixes

  • do not end not started streams (fb8cb95)

Features

  • match expectation on start (that dials are done) (b802af9)

0.7.0 (2017-01-09)

Features

  • add start and stop to FloodSub (c7d1c57)

0.6.0 (2016-12-21)

Features

  • emit full messages, instead of just data (#13) (300bf95)

0.5.0 (2016-12-18)

0.4.1 (2016-12-11)

Bug Fixes

  • pass subscriptions immediately on new peer connection (#10) (078383a)

0.4.0 (2016-11-28)

0.3.1 (2016-11-17)

Features

  • remove fs as a dependency + update aegir (e6ae36b)

0.3.0 (2016-09-14)

0.2.0 (2016-09-14)

0.1.0 (2016-09-14)