@libp2p/floodsub 9.0.11 → 9.0.12
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 +25 -6
- package/dist/index.min.js +3 -3
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -6
- package/dist/src/index.js.map +1 -1
- package/package.json +11 -10
- package/src/index.ts +8 -6
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# @libp2p/floodsub
|
|
2
|
+
|
|
1
3
|
[](http://libp2p.io/)
|
|
2
4
|
[](https://discuss.libp2p.io)
|
|
3
5
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,6 +9,21 @@
|
|
|
7
9
|
|
|
8
10
|
# About
|
|
9
11
|
|
|
12
|
+
<!--
|
|
13
|
+
|
|
14
|
+
!IMPORTANT!
|
|
15
|
+
|
|
16
|
+
Everything in this README between "# About" and "# Install" is automatically
|
|
17
|
+
generated and will be overwritten the next time the doc generator is run.
|
|
18
|
+
|
|
19
|
+
To make changes to this section, please update the @packageDocumentation section
|
|
20
|
+
of src/index.js or src/index.ts
|
|
21
|
+
|
|
22
|
+
To experiment with formatting, please run "npm run docs" from the root of this
|
|
23
|
+
repo and examine the changes made.
|
|
24
|
+
|
|
25
|
+
-->
|
|
26
|
+
|
|
10
27
|
> Don't use this module
|
|
11
28
|
|
|
12
29
|
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.
|
|
@@ -18,21 +35,23 @@ Instead please use [gossipsub](https://www.npmjs.com/package/@chainsafe/libp2p-g
|
|
|
18
35
|
## Example - Configuring libp2p to use floodsub
|
|
19
36
|
|
|
20
37
|
```TypeScript
|
|
21
|
-
import {
|
|
38
|
+
import { createLibp2p } from 'libp2p'
|
|
22
39
|
import { floodsub } from '@libp2p/floodsub'
|
|
23
40
|
|
|
24
|
-
const node = await
|
|
25
|
-
|
|
41
|
+
const node = await createLibp2p({
|
|
42
|
+
services: {
|
|
43
|
+
pubsub: floodsub()
|
|
44
|
+
}
|
|
26
45
|
//... other options
|
|
27
46
|
})
|
|
28
47
|
await node.start()
|
|
29
48
|
|
|
30
|
-
node.pubsub.subscribe('fruit')
|
|
31
|
-
node.pubsub.addEventListener('message', (evt) => {
|
|
49
|
+
node.services.pubsub.subscribe('fruit')
|
|
50
|
+
node.services.pubsub.addEventListener('message', (evt) => {
|
|
32
51
|
console.log(evt)
|
|
33
52
|
})
|
|
34
53
|
|
|
35
|
-
node.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
54
|
+
node.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
36
55
|
```
|
|
37
56
|
|
|
38
57
|
# Install
|