14.1.0 • Published 1 year ago

@chainsafe/libp2p-gossipsub v14.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

js-libp2p-gossipsub

npm.io Travis CI ES Version Node Version

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 @chainsafe/libp2p-gossipsub

Usage

import { gossipsub } from '@chainsafe/libp2p-gossipsub'


const libp2p = await createLibp2p({
  // ...
  services: {
    pubsub: gossipsub(options)
  }
});

libp2p.services.pubsub.addEventListener('message', (message) => {
  console.log(`${message.detail.topic}:`, new TextDecoder().decode(message.detail.data))
})

libp2p.services.pubsub.subscribe('fruit')

libp2p.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))

API

Create a gossipsub implementation

const options = {…}
const gossipsub = gossipsub(options)(libp2p)

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/interface-pubsub.

Contribute

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

License

MIT © ChainSafe Systems

@infinitebrahmanuniverse/nolb-_chai@everything-registry/sub-chunk-164electron-forge-react-typescript-boilerplateweb3crdt@canvas-js/gossiplogipfs-nodejs-ds-crdtjs-wakuipfs_blockchainipfs-core-configipdwhelia-ipfs-nodelibp2p_kit_jslibp2p-tskiwistand@waku/relay@windingtree/sdk-pubsub@windingtree/sdk@turbo-ing/edge-v0@ts-drp/network@ts-drp/node@topology-foundation/network@topology-foundation/node@constl/utils-tests@constl/iparivalz-client-node-librivalz-client-nodedenetwork-relay@bpx-chain/synapse-relay@carmel/core@byzanlink-bundler/nodewebpeerjs@lodestar/beacon-node@libertynet/core@libp2p/daemon-servermtcrawleemoonbase-jsmiracle-node-clip4ppeerseyosit_vertifyerosint_vertifyerplugin-payairivalz-node-clientrivalz-client-libdecontactdebeem-libdebeem-p2p-relayfetchize@openibex/core@orbitdb/liftoff@orbitdb/quickstart@orbitdb/voyager@ordao/ornode@olptools/node@rosen-bridge/rosenet-node@rosen-bridge/rosenet-relay@debros/network@dwn-protocol/dwn@dwn-protocol/id-sdk@drtc/bootstrap@drtc/bootstrap-node@drtc/create@drtc/relay@drtc/relay-node@drtc/tests@helia/interop@helia/cli-utils@djack-sdk/network@djack-sdk/signal@filecoin-renewable-energy-purchases/js-api@fatduckai/ai@savid/libp2p-pest@othentic/othentic-cli@othentic/othentic-cli-sepolia@nabladelta/lambdadelta@sfroment/network@sfroment/node@0xvaibhav/libp2p-events@skandha/node@sinugrepo/rivalz-mod-cli@abaxx/sdk@autismjs/protocol@aldea/mocknet@aztec/p2p@badaimweeb/js-protov2@soketi/p2p@bitxenia/astradb@blockless/browser-node@riffcc/constl-ipa-fork@riffcc/lens-node
14.1.0

1 year ago

14.0.0

1 year ago

13.1.1

1 year ago

13.1.0

1 year ago

13.2.0

1 year ago

13.0.0

2 years ago

12.0.0

2 years ago

11.2.1

2 years ago

11.2.0

2 years ago

11.1.0

2 years ago

11.0.1

2 years ago

11.0.0

2 years ago

10.0.0

2 years ago

10.1.0

2 years ago

10.1.1

2 years ago

9.1.0

2 years ago

8.0.1

2 years ago

9.0.0

2 years ago

8.0.0

2 years ago

6.3.0

3 years ago

7.0.0

3 years ago

6.2.0

3 years ago

6.1.0

3 years ago

6.0.0

3 years ago

5.4.1

3 years ago

5.4.0

3 years ago

5.3.0

3 years ago

5.2.1

3 years ago

5.2.0

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.1.0

3 years ago

4.1.1

3 years ago

3.4.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

3.3.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

3.2.0

3 years ago

3.0.2

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.5.1

3 years ago

3.5.0

3 years ago

3.0.0

3 years ago

1.1.2

3 years ago

4.0.0

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago