Gossipsub is an implementation of pubsub based on meshsub and floodsub.
You can read the specification here.
@libp2p/gossipsub currently implements version 1.1 of the spec.
@libp2p/gossipsub
Formerly published as @chainsafe/libp2p-gossipsub.
@chainsafe/libp2p-gossipsub
import { identify } from '@libp2p/identify'import { createLibp2p } from 'libp2p'import { gossipsub } from '@libp2p/gossipsub'const node = await createLibp2p({ services: { identify: identify(), pubsub: gossipsub() } //... other options})await node.start()node.services.pubsub.addEventListener('message', (evt) => { console.log(`${evt.detail.topic}:`, new TextDecoder().decode(evt.detail.data))})node.services.pubsub.subscribe('fruit')node.services.pubsub.publish('fruit', new TextEncoder().encode('banana')) Copy
import { identify } from '@libp2p/identify'import { createLibp2p } from 'libp2p'import { gossipsub } from '@libp2p/gossipsub'const node = await createLibp2p({ services: { identify: identify(), pubsub: gossipsub() } //... other options})await node.start()node.services.pubsub.addEventListener('message', (evt) => { console.log(`${evt.detail.topic}:`, new TextDecoder().decode(evt.detail.data))})node.services.pubsub.subscribe('fruit')node.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))
Gossipsub is an implementation of pubsub based on meshsub and floodsub.
You can read the specification here.
@libp2p/gossipsubcurrently implements version 1.1 of the spec.Formerly published as
@chainsafe/libp2p-gossipsub.Example: Configuring libp2p to use gossipsub