libp2p-floodsub
0.4.1

Intro

Installable via npm install --save libp2p-floodsub, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save libp2p-floodsub

You can then require() libp2p-floodsub as normal:

const libp2PFloodsub = require('libp2p-floodsub')

In the Browser

Libp2p-floodsub should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of libp2p-floodsub, including index.js and index.min.js, are included in the /dist folder. Libp2p-floodsub can also be found on unkpkg.com under

PubSubGossip

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

Extends EventEmitter.

instance

constructor

constructor(libp2p: Object, dagService: Object): PubSubGossip

Parameters

  1. libp2p: Object:  
  2. dagService: Object:  

Returns

PubSubGossip.prototype.cache

cache: TimeCache

Time based cache for sequence numbers.

PubSubGossip.prototype.peers

peers: Map<string, Peer>

Map of peers.

PubSubGossip.prototype.subscriptions

subscriptions: Set<string>

List of our subscriptions

PubSubGossip.prototype.publish

publish(topics: (Array<string> | string), messages: (Array<any> | any)): undefined

Publish messages to the given topics.

Parameters

  1. topics: (Array<string> | string):  
  2. messages: (Array<any> | any):  

Returns

PubSubGossip.prototype.subscribe

subscribe(topics: (Array<string> | string)): undefined

Subscribe to the given topic(s).

Parameters

  1. topics: (Array<string> | string):  

Returns

PubSubGossip.prototype.unsubscribe

unsubscribe(topics: (Array<string> | string)): undefined

Unsubscribe from the given topic(s).

Parameters

  1. topics: (Array<string> | string):  

Returns

Peer

The known state of a connected peer.

instance

Peer.prototype.info

info: PeerInfo

Peer.prototype.conn

conn: Connection

Peer.prototype.topics

topics: Set

Peer.prototype.stream

stream: Pushable

Peer.prototype.isConnected

isConnected: boolean

Is the peer connected currently?

Peer.prototype.isWritable

isWritable: boolean

Do we have a connection to write on?

Peer.prototype.write

write(msg: Buffer): undefined

Send a message to this peer. Throws if there is no stream to write to available.

Parameters

  1. msg: Buffer:  

Returns