@libp2p/floodsub
Version:
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).
44 lines • 1.47 kB
TypeScript
/**
* @packageDocumentation
*
* > Don't use this module
*
* This module is a naive implementation of pubsub. It broadcasts all messages to all network peers, cannot provide older messages and has no protection against bad actors.
*
* It exists for academic purposes only, you should not use it in production.
*
* Instead please use [gossipsub](https://www.npmjs.com/package/@chainsafe/libp2p-gossipsub) - a more complete implementation which is also compatible with floodsub.
*
* @example Configuring libp2p to use floodsub
*
* ```TypeScript
* import { createLibp2p } from 'libp2p'
* import { floodsub } from '@libp2p/floodsub'
*
* const node = await createLibp2p({
* services: {
* pubsub: floodsub()
* }
* //... other options
* })
* await node.start()
*
* node.services.pubsub.subscribe('fruit')
* node.services.pubsub.addEventListener('message', (evt) => {
* console.log(evt)
* })
*
* node.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))
* ```
*/
import { type PubSubComponents } from '@libp2p/pubsub';
import { multicodec } from './config.js';
import type { PubSubInit, PubSub } from '@libp2p/interface';
export { multicodec };
export interface FloodSubInit extends PubSubInit {
seenTTL?: number;
}
export interface FloodSubComponents extends PubSubComponents {
}
export declare function floodsub(init?: FloodSubInit): (components: FloodSubComponents) => PubSub;
//# sourceMappingURL=index.d.ts.map