@libp2p/floodsub 1.0.7 → 2.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 +37 -26
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/index.ts +2 -2
package/README.md
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @libp2p/floodsub <!-- omit in toc -->
|
|
2
2
|
|
|
3
|
-
[](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml)
|
|
9
|
-
[](https://david-dm.org/libp2p/js-libp2p-floodsub) [](https://github.com/feross/standard)
|
|
10
|
-
[](https://waffle.io/libp2p/js-libp2p-floodsub)
|
|
3
|
+
[](http://libp2p.io/)
|
|
4
|
+
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
|
+
[](https://discuss.libp2p.io)
|
|
6
|
+
[](https://codecov.io/gh/libp2p/js-libp2p-floodsub)
|
|
7
|
+
[](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml)
|
|
11
8
|
|
|
12
9
|
> 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).
|
|
13
10
|
|
|
14
|
-
## Table of
|
|
11
|
+
## Table of contents <!-- omit in toc -->
|
|
15
12
|
|
|
16
13
|
- [Install](#install)
|
|
17
14
|
- [Usage](#usage)
|
|
@@ -20,11 +17,12 @@
|
|
|
20
17
|
- [Events](#events)
|
|
21
18
|
- [Contribute](#contribute)
|
|
22
19
|
- [License](#license)
|
|
20
|
+
- [Contribution](#contribution)
|
|
23
21
|
|
|
24
22
|
## Install
|
|
25
23
|
|
|
26
|
-
```
|
|
27
|
-
|
|
24
|
+
```console
|
|
25
|
+
$ npm i @libp2p/floodsub
|
|
28
26
|
```
|
|
29
27
|
|
|
30
28
|
## Usage
|
|
@@ -56,26 +54,32 @@ const floodsub = new Floodsub(peerId, registrar, options)
|
|
|
56
54
|
|
|
57
55
|
Options is an optional object with the following key-value pairs:
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
- **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **false**).
|
|
60
58
|
|
|
61
|
-
For the remaining API, see https://github.com/libp2p/js-libp2p-pubsub
|
|
59
|
+
For the remaining API, see <https://github.com/libp2p/js-libp2p-pubsub>
|
|
62
60
|
|
|
63
61
|
## Events
|
|
64
62
|
|
|
65
63
|
Floodsub emits two kinds of events:
|
|
64
|
+
|
|
66
65
|
1. `<topic>` when a message is received for a particular topic
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
|
|
67
|
+
```Javascript
|
|
68
|
+
fsub.on('fruit', (data) => { ... })
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- `data`: a Uint8Array containing the data that was published to the topic
|
|
72
|
+
|
|
71
73
|
2. `floodsub:subscription-change` when the local peer receives an update to the subscriptions of a remote peer.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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 } ]`
|
|
79
83
|
|
|
80
84
|
## Contribute
|
|
81
85
|
|
|
@@ -85,4 +89,11 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c
|
|
|
85
89
|
|
|
86
90
|
## License
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
Licensed under either of
|
|
93
|
+
|
|
94
|
+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
95
|
+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
96
|
+
|
|
97
|
+
## Contribution
|
|
98
|
+
|
|
99
|
+
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/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PubSubBaseProtocol } from '@libp2p/pubsub';
|
|
2
2
|
import { multicodec } from './config.js';
|
|
3
3
|
import { SimpleTimeCache } from './cache.js';
|
|
4
|
-
import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult } from '@libp2p/
|
|
5
|
-
import type { PeerId } from '@libp2p/
|
|
4
|
+
import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult } from '@libp2p/interface-pubsub';
|
|
5
|
+
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
6
6
|
export { multicodec };
|
|
7
7
|
export interface FloodSubInit extends PubSubInit {
|
|
8
8
|
seenTTL?: number;
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC/G,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAMvD,OAAO,EAAE,UAAU,EAAE,CAAA;AAErB,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,kBAAkB;IACvC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;gBAE7B,IAAI,CAAC,EAAE,YAAY;IAiBhC;;OAEG;IACH,SAAS,CAAE,KAAK,EAAE,UAAU,GAAG,SAAS;IAIxC;;OAEG;IACH,SAAS,CAAE,GAAG,EAAE,SAAS,GAAG,UAAU;IAItC,aAAa,CAAE,KAAK,EAAE,UAAU,GAAG,gBAAgB;IAInD,aAAa,CAAE,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAIjD;;;OAGG;IACG,cAAc,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAcpD;;OAEG;IACG,cAAc,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CA4B9E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/floodsub",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
36
|
+
"types": "./src/index.d.ts",
|
|
36
37
|
"import": "./dist/src/index.js"
|
|
37
38
|
}
|
|
38
39
|
},
|
|
@@ -142,19 +143,22 @@
|
|
|
142
143
|
"release": "aegir release"
|
|
143
144
|
},
|
|
144
145
|
"dependencies": {
|
|
145
|
-
"@libp2p/
|
|
146
|
+
"@libp2p/interface-peer-id": "^1.0.2",
|
|
147
|
+
"@libp2p/interface-pubsub": "^1.0.1",
|
|
146
148
|
"@libp2p/logger": "^1.1.4",
|
|
147
|
-
"@libp2p/pubsub": "^
|
|
149
|
+
"@libp2p/pubsub": "^2.0.0",
|
|
148
150
|
"protons-runtime": "^1.0.3",
|
|
149
151
|
"uint8arrays": "^3.0.0"
|
|
150
152
|
},
|
|
151
153
|
"devDependencies": {
|
|
152
|
-
"@libp2p/
|
|
154
|
+
"@libp2p/components": "^1.0.0",
|
|
155
|
+
"@libp2p/interface-mocks": "^1.0.1",
|
|
156
|
+
"@libp2p/interface-pubsub-compliance-tests": "^1.0.1",
|
|
153
157
|
"@libp2p/peer-collections": "^1.0.2",
|
|
154
158
|
"@libp2p/peer-id": "^1.1.10",
|
|
155
159
|
"@libp2p/peer-id-factory": "^1.0.9",
|
|
156
160
|
"@multiformats/multiaddr": "^10.1.8",
|
|
157
|
-
"aegir": "^37.0
|
|
161
|
+
"aegir": "^37.2.0",
|
|
158
162
|
"multiformats": "^9.4.5",
|
|
159
163
|
"p-wait-for": "^4.1.0",
|
|
160
164
|
"protons": "^3.0.3",
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { toString } from 'uint8arrays/to-string'
|
|
|
2
2
|
import { PubSubBaseProtocol } from '@libp2p/pubsub'
|
|
3
3
|
import { multicodec } from './config.js'
|
|
4
4
|
import { SimpleTimeCache } from './cache.js'
|
|
5
|
-
import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult } from '@libp2p/
|
|
6
|
-
import type { PeerId } from '@libp2p/
|
|
5
|
+
import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult } from '@libp2p/interface-pubsub'
|
|
6
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
7
7
|
import { logger } from '@libp2p/logger'
|
|
8
8
|
import { RPC } from './message/rpc.js'
|
|
9
9
|
|