@libp2p/floodsub 4.0.1 → 6.0.0
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.
- package/README.md +23 -12
- package/dist/index.min.js +24 -0
- package/dist/src/index.d.ts +6 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/message/rpc.d.ts.map +1 -1
- package/dist/src/message/rpc.js +93 -102
- package/dist/src/message/rpc.js.map +1 -1
- package/package.json +15 -16
- package/src/index.ts +13 -5
- package/src/message/rpc.ts +93 -93
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# @libp2p/floodsub <!-- omit in toc -->
|
|
2
2
|
|
|
3
3
|
[](http://libp2p.io/)
|
|
4
|
-
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
4
|
[](https://discuss.libp2p.io)
|
|
6
5
|
[](https://codecov.io/gh/libp2p/js-libp2p-floodsub)
|
|
7
|
-
[](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
|
|
8
7
|
|
|
9
8
|
> 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).
|
|
10
9
|
|
|
11
10
|
## Table of contents <!-- omit in toc -->
|
|
12
11
|
|
|
13
12
|
- [Install](#install)
|
|
13
|
+
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
14
|
- [Don't use this module](#dont-use-this-module)
|
|
15
15
|
- [Usage](#usage)
|
|
16
16
|
- [License](#license)
|
|
17
|
-
- [
|
|
17
|
+
- [Contribution](#contribution)
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
$ npm i @libp2p/floodsub
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
### Browser `<script>` tag
|
|
26
|
+
|
|
27
|
+
Loading this module through a script tag will make it's exports available as `Libp2pFloodsub` in the global namespace.
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<script src="https://unpkg.com/@libp2p/floodsub/dist/index.min.js"></script>
|
|
31
|
+
```
|
|
32
|
+
|
|
25
33
|
## Don't use this module
|
|
26
34
|
|
|
27
35
|
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.
|
|
@@ -33,18 +41,21 @@ Instead please use [gossipsub](https://www.npmjs.com/package/@chainsafe/libp2p-g
|
|
|
33
41
|
## Usage
|
|
34
42
|
|
|
35
43
|
```JavaScript
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
const fsub = new FloodSub()
|
|
44
|
+
import { createLibp2pNode } from 'libp2p'
|
|
45
|
+
import { floodsub } from '@libp2p/floodsub'
|
|
39
46
|
|
|
40
|
-
await
|
|
47
|
+
const node = await createLibp2pNode({
|
|
48
|
+
pubsub: floodsub()
|
|
49
|
+
//... other options
|
|
50
|
+
})
|
|
51
|
+
await node.start()
|
|
41
52
|
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
node.pubsub.subscribe('fruit')
|
|
54
|
+
node.pubsub.addEventListener('message', (evt) => {
|
|
55
|
+
console.log(evt)
|
|
44
56
|
})
|
|
45
|
-
fsub.subscribe('fruit')
|
|
46
57
|
|
|
47
|
-
|
|
58
|
+
node.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
48
59
|
```
|
|
49
60
|
|
|
50
61
|
## License
|
|
@@ -54,6 +65,6 @@ Licensed under either of
|
|
|
54
65
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
55
66
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
56
67
|
|
|
57
|
-
##
|
|
68
|
+
## Contribution
|
|
58
69
|
|
|
59
70
|
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.
|