@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 CHANGED
@@ -1,17 +1,14 @@
1
- # js-libp2p-floodsub <!-- omit in toc -->
1
+ # @libp2p/floodsub <!-- omit in toc -->
2
2
 
3
- [![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
4
- [![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
5
- [![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
6
- [![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
7
- [![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-floodsub/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-floodsub?branch=master)
8
- [![Build Status](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml/badge.svg?branch=main)](https://github.com/libp2p/js-libp2p-floodsub/actions/workflows/js-test-and-release.yml)
9
- [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-floodsub.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-floodsub) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
10
- [![](https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square)](https://waffle.io/libp2p/js-libp2p-floodsub)
3
+ [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
+ [![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
5
+ [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
6
+ [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-floodsub.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-floodsub)
7
+ [![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](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 Contents <!-- omit in toc -->
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
- ```sh
27
- > npm install @libp2p/floodsub
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
- * **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **false**).
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
- ```Javascript
68
- fsub.on('fruit', (data) => { ... })
69
- ```
70
- - `data`: a Uint8Array containing the data that was published to the 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
+
71
73
  2. `floodsub:subscription-change` when the local peer receives an update to the subscriptions of a remote peer.
72
- ```Javascript
73
- fsub.on('floodsub:subscription-change', (peerId, topics, changes) => { ... })
74
- ```
75
- - `peerId`: a [PeerId](https://github.com/libp2p/js-peer-id) object
76
- - `topics`: the topics that the peer is now subscribed to
77
- - `changes`: an array of `{ topicID: <topic>, subscribe: <boolean> }`
78
- eg `[ { topicID: 'fruit', subscribe: true }, { topicID: 'vegetables': false } ]`
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
- [Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs
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.
@@ -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/interfaces/pubsub';
5
- import type { PeerId } from '@libp2p/interfaces/peer-id';
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;
@@ -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,2BAA2B,CAAA;AAChH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAMxD,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"}
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": "1.0.7",
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/interfaces": "^2.0.1",
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": "^1.2.20",
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/interface-compliance-tests": "^2.0.1",
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.14",
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/interfaces/pubsub'
6
- import type { PeerId } from '@libp2p/interfaces/peer-id'
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