Detalhes do pacote

libp2p-gossipsub

ChainSafe18.2kApache-2.00.13.0

A typescript implementation of gossipsub

libp2p, pubsub, gossip

readme (leia-me)

js-libp2p-gossipsub

Travis CI ES Version Node Version

Lead Maintainer

Cayman Nava

Table of Contents

Specs

Gossipsub is an implementation of pubsub based on meshsub and floodsub. You can read the specification here.

libp2p-gossipsub currently implements the v1.1 of the spec.

Install

npm install libp2p-gossipsub

Usage

const Gossipsub = require('libp2p-gossipsub')

const gsub = new Gossipsub(libp2p, options)

await gsub.start()

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

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

API

Create a gossipsub implementation

const options = {…}
const gossipsub = new Gossipsub(libp2p, 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).
  • gossipIncoming: boolean identifying if incoming messages on a subscribed topic should be automatically gossiped (defaults to true).
  • fallbackToFloodsub: boolean identifying whether the node should fallback to the floodsub protocol, if another connecting peer does not support gossipsub (defaults to true).
  • floodPublish: boolean identifying if self-published messages should be sent to all peers, (defaults to true).
  • doPX: boolean identifying whether PX is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes (defaults to false).
  • msgIdFn: a function with signature (message) => string defining the message id given a message, used internally to deduplicate gossip (defaults to (message) => message.from + message.seqno.toString('hex'))
  • signMessages: boolean identifying if we want to sign outgoing messages or not (default: true)
  • strictSigning: boolean identifying if message signing is required for incoming messages or not (default: true)
  • messageCache: optional, a customized MessageCache instance, see the implementation for the interface.
  • scoreParams: optional, a customized peer score parameters Object.
  • scoreThresholds: optional, a customized peer score thresholds Object.
  • directPeers: optional, an array of AddrInfo of peers with which we will maintain direct connections.

For the remaining API, see libp2p-interfaces/pubsub.

Contribute

This module is actively under development. Please check out the issues and submit PRs!

License

MIT © ChainSafe Systems

changelog (log de mudanças)

0.13.0 (2022-01-20)

0.12.2 (2022-01-20)

Features

BREAKING CHANGES

  • peerstore methods and pubsub start/stop are now all async

Features

  • Add optional fast message id cache via the fastMsgIdFn option
    • In certain applications, computing the message id (getMsgId) is relatively expensive. This addition allows for an application to optionally define a "fast" message id function that will be used internally.
  • Add optional cached message id function via getCachedMsgIdStr method override
    • Applications can maintain their own cache of message ids

0.12.1 (2021-12-03)

0.12.0 (2021-12-02)

chore

BREAKING CHANGES

  • requires node 15+

0.11.4 (2021-09-20)

Bug Fixes

Features

0.11.3 (2021-09-03)

0.11.2 (2021-09-02)

0.11.1 (2021-08-24)

0.11.0 (2021-07-09)

chore

BREAKING CHANGES

  • the new peer-id module uses the new CID class and not the old one

0.10.0 (2021-05-28)

0.9.2 (2021-05-28)

Reverts

  • Revert "chore: update pubsub interface to run subsystem tests (#148)" (87607fb), closes #148

0.9.1 (2021-05-28)

0.9.0 (2021-04-28)

0.8.0 (2020-12-19)

0.7.0 (2020-11-13)

0.6.6 (2020-11-13)

0.6.5 (2020-11-12)

0.6.4 (2020-10-22)

0.6.3 (2020-10-05)

0.6.2 (2020-09-22)

0.6.1 (2020-09-03)

0.6.0 (2020-08-25)

Bug Fixes

Features

  • add _acceptFrom filter (1ff5816)
  • add adaptive gossip (0c56763)
  • add direct peer connections (7103b83)
  • add extended topic validators (a1208b6)
  • add flood publishing (5854d26)
  • add invalid message spam protection (27fe567)
  • add iwant request tracking (b3942e4)
  • add opportunistic grafting (cbee3a2)
  • add outbound mesh quota (47bc4a7)
  • add peer exchange (a0a691b)
  • add prune backoff (4eb492c)
  • libp2p as gossipsub parameter (02dff12)
  • track ihave/iwant counts (8e04a11)

BREAKING CHANGES

  • Gossipsub default export parameter changed, now accepts (libp2p, options)

0.5.0 (2020-08-12)

Bug Fixes

  • replace node buffers with uint8arrays (#118) (2f50108)

BREAKING CHANGES

    • The .data and .seq properties of messages used to be node Buffers, now they are Uint8Arrays
  • All deps of this module now use Uint8Arrays instead of Buffers

  • chore: remove gh url from dep version

0.4.6 (2020-07-07)

Bug Fixes

  • connected with a subscriber before a mesh is created should send messages (060346a)

0.4.5 (2020-06-04)

Bug Fixes

0.4.4 (2020-06-03)

Bug Fixes

  • add static member for multicodec (#81) (dd86739)

0.4.3 (2020-06-03)

0.4.2 (2020-05-27)

Features

  • add topic validators to pubsub (5712fd1)

0.4.1 (2020-05-27)

0.4.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.3.0 (2020-04-23)

Bug Fixes

  • add buffer and update deps (d8e9d1b)

0.2.6 (2020-04-04)

0.2.5 (2020-03-21)

0.2.4 (2020-02-14)

Bug Fixes

0.2.3 (2020-02-03)

Bug Fixes

Chores

Code Refactoring

  • switch to async iterators (3027835)

Performance Improvements

BREAKING CHANGES

  • getPeersSubscribed from parent class renamed to getSubscribers to remove redundant wording
  • Switch to using async/await and async iterators for all the API. Moreover, gossipsub does not need the libp2p instance anymore, receiving a registerar that enables it to receive the necessary events from libp2p

0.2.2 (2020-01-24)

Bug Fixes

Chores

Code Refactoring

  • switch to async iterators (3027835)

BREAKING CHANGES

  • getPeersSubscribed from parent class renamed to getSubscribers to remove redundant wording
  • Switch to using async/await and async iterators for all the API. Moreover, gossipsub does not need the libp2p instance anymore, receiving a registerar that enables it to receive the necessary events from libp2p

0.2.1 (2019-01-14)

Bug Fixes

0.2.0 (2019-12-02)

Chores

BREAKING CHANGES

  • getPeersSubscribed from parent class renamed to getSubscribers to remove redundant wording.

0.1.0 (2019-19-14)

Code Refactoring

  • switch to async iterators (ec8db51)

BREAKING CHANGES

  • Switch to using async/await and async iterators.

0.0.2 (2019-06-04)

0.0.1 (2019-06-04)

Bug Fixes

  • integration with js-libp2p (f894281)