Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
/ js-libp2p-floodsub Public archive

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

License

Notifications You must be signed in to change notification settings

libp2p/js-libp2p-floodsub

Repository files navigation

📁 Archived - this module has been merged into js-libp2p

@libp2p/floodsub

libp2p.io Discuss codecov CI

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

Table of contents

Install

$ npm i @libp2p/floodsub

Browser <script> tag

Loading this module through a script tag will make it's exports available as Libp2pFloodsub in the global namespace.

<script src="https://unpkg.com/@libp2p/floodsub/dist/index.min.js"></script>

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 - a more complete implementation which is also compatible with floodsub.

Usage

import { createLibp2pNode } from 'libp2p'
import { floodsub } from '@libp2p/floodsub'

const node = await createLibp2pNode({
  pubsub: floodsub()
  //... other options
})
await node.start()

node.pubsub.subscribe('fruit')
node.pubsub.addEventListener('message', (evt) => {
  console.log(evt)
})

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

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published