@libp2p/floodsub 3.0.6 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +13 -53
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -11,13 +11,10 @@
11
11
  ## Table of contents <!-- omit in toc -->
12
12
 
13
13
  - [Install](#install)
14
+ - [Don't use this module](#dont-use-this-module)
14
15
  - [Usage](#usage)
15
- - [API](#api)
16
- - [Create a floodsub implementation](#create-a-floodsub-implementation)
17
- - [Events](#events)
18
- - [Contribute](#contribute)
19
16
  - [License](#license)
20
- - [Contribution](#contribution)
17
+ - [Contribute](#contribute)
21
18
 
22
19
  ## Install
23
20
 
@@ -25,17 +22,24 @@
25
22
  $ npm i @libp2p/floodsub
26
23
  ```
27
24
 
25
+ ## Don't use this module
26
+
27
+ 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.
28
+
29
+ It exists for academic purposes only, you should not use it in production.
30
+
31
+ Instead please use [gossipsub](https://www.npmjs.com/package/@chainsafe/libp2p-gossipsub) - a more complete implementation which is also compatible with floodsub.
32
+
28
33
  ## Usage
29
34
 
30
35
  ```JavaScript
31
36
  import { FloodSub } from '@libp2p/floodsub'
32
37
 
33
- // registrar is provided by libp2p
34
- const fsub = new FloodSub(peerId, registrar, options)
38
+ const fsub = new FloodSub()
35
39
 
36
40
  await fsub.start()
37
41
 
38
- fsub.on('fruit', (data) => {
42
+ fsub.addEventListener('message', (data) => {
39
43
  console.log(data)
40
44
  })
41
45
  fsub.subscribe('fruit')
@@ -43,50 +47,6 @@ fsub.subscribe('fruit')
43
47
  fsub.publish('fruit', new TextEncoder().encode('banana'))
44
48
  ```
45
49
 
46
- ## API
47
-
48
- ### Create a floodsub implementation
49
-
50
- ```js
51
- const options = {…}
52
- const floodsub = new Floodsub(peerId, registrar, options)
53
- ```
54
-
55
- Options is an optional object with the following key-value pairs:
56
-
57
- - **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **false**).
58
-
59
- For the remaining API, see <https://github.com/libp2p/js-libp2p-pubsub>
60
-
61
- ## Events
62
-
63
- Floodsub emits two kinds of events:
64
-
65
- 1. `<topic>` when a message is received for a particular topic
66
-
67
- ```Javascript
68
- fsub.on('fruit', (data) => { ... })
69
- ```
70
-
71
- - `data`: a Uint8Array containing the data that was published to the topic
72
-
73
- 2. `floodsub:subscription-change` when the local peer receives an update to the subscriptions of a remote peer.
74
-
75
- ```Javascript
76
- fsub.on('floodsub:subscription-change', (peerId, topics, changes) => { ... })
77
- ```
78
-
79
- - `peerId`: a [PeerId](https://github.com/libp2p/js-peer-id) object
80
- - `topics`: the topics that the peer is now subscribed to
81
- - `changes`: an array of `{ topicID: <topic>, subscribe: <boolean> }`
82
- eg `[ { topicID: 'fruit', subscribe: true }, { topicID: 'vegetables': false } ]`
83
-
84
- ## Contribute
85
-
86
- Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-libp2p-pubsub/issues)!
87
-
88
- This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
89
-
90
50
  ## License
91
51
 
92
52
  Licensed under either of
@@ -94,6 +54,6 @@ Licensed under either of
94
54
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
95
55
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
96
56
 
97
- ## Contribution
57
+ ## Contribute
98
58
 
99
59
  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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/floodsub",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "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).",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p-floodsub#readme",