@libp2p/gossipsub 17.1.1 → 17.1.2-776cdedf6
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 +56 -52
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/src/constants.d.ts +3 -3
- package/dist/src/constants.js +3 -3
- package/dist/src/gossipsub.js +8 -8
- package/dist/src/gossipsub.js.map +1 -1
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +36 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/metrics.d.ts +1 -1
- package/dist/src/metrics.d.ts.map +1 -1
- package/dist/src/metrics.js +1 -1
- package/dist/src/metrics.js.map +1 -1
- package/dist/src/score/peer-score-params.d.ts +1 -1
- package/dist/src/score/peer-score-params.js +1 -1
- package/dist/src/score/peer-score-params.js.map +1 -1
- package/dist/src/score/peer-score-thresholds.d.ts +2 -2
- package/dist/src/score/peer-score.d.ts +2 -2
- package/dist/src/score/peer-score.d.ts.map +1 -1
- package/dist/src/tracer.js +1 -1
- package/dist/src/utils/buildRawMessage.js +2 -2
- package/dist/src/utils/buildRawMessage.js.map +1 -1
- package/package.json +18 -13
- package/src/constants.ts +3 -3
- package/src/gossipsub.ts +8 -8
- package/src/index.ts +37 -0
- package/src/message/rpc.proto +1 -1
- package/src/metrics.ts +1 -1
- package/src/score/peer-score-params.ts +2 -2
- package/src/score/peer-score-thresholds.ts +2 -2
- package/src/score/peer-score.ts +2 -2
- package/src/tracer.ts +1 -1
- package/src/utils/buildRawMessage.ts +2 -2
- package/dist/typedoc-urls.json +0 -197
package/README.md
CHANGED
|
@@ -1,83 +1,87 @@
|
|
|
1
1
|
# @libp2p/gossipsub
|
|
2
2
|
|
|
3
|
-
](http://libp2p.io/)
|
|
4
|
+
[](https://discuss.libp2p.io)
|
|
5
|
+
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
6
|
+
[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
> A typescript implementation of gossipsub
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
- [Lead Maintainer](#lead-maintainer)
|
|
10
|
-
- [Table of Contents](#table-of-contents)
|
|
11
|
-
- [Specs](#specs)
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Usage](#usage)
|
|
14
|
-
- [API](#api)
|
|
15
|
-
- [Create a gossipsub implementation](#create-a-gossipsub-implementation)
|
|
16
|
-
- [Contribute](#contribute)
|
|
17
|
-
- [License](#license)
|
|
10
|
+
# About
|
|
18
11
|
|
|
19
|
-
|
|
12
|
+
<!--
|
|
20
13
|
|
|
21
|
-
|
|
14
|
+
!IMPORTANT!
|
|
22
15
|
|
|
23
|
-
|
|
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.
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
To make changes to this section, please update the @packageDocumentation section
|
|
20
|
+
of src/index.js or src/index.ts
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
To experiment with formatting, please run "npm run docs" from the root of this
|
|
23
|
+
repo and examine the changes made.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
-->
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
Gossipsub is an implementation of pubsub based on meshsub and floodsub.
|
|
28
|
+
|
|
29
|
+
You can read the specification [here](https://github.com/libp2p/specs/tree/master/pubsub/gossipsub).
|
|
30
|
+
|
|
31
|
+
`@libp2p/gossipsub` currently implements [version 1.1](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) of the spec.
|
|
32
|
+
|
|
33
|
+
Formerly published as [`@chainsafe/libp2p-gossipsub`](https://www.npmjs.com/package/@chainsafe/libp2p-gossipsub).
|
|
34
|
+
|
|
35
|
+
## Example - Configuring libp2p to use gossipsub
|
|
33
36
|
|
|
37
|
+
```typescript
|
|
38
|
+
import { identify } from '@libp2p/identify'
|
|
39
|
+
import { createLibp2p } from 'libp2p'
|
|
40
|
+
import { gossipsub } from '@libp2p/gossipsub'
|
|
34
41
|
|
|
35
|
-
const
|
|
36
|
-
// ...
|
|
42
|
+
const node = await createLibp2p({
|
|
37
43
|
services: {
|
|
38
|
-
|
|
44
|
+
identify: identify(),
|
|
45
|
+
pubsub: gossipsub()
|
|
39
46
|
}
|
|
40
|
-
|
|
47
|
+
//... other options
|
|
48
|
+
})
|
|
49
|
+
await node.start()
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
console.log(`${
|
|
51
|
+
node.services.pubsub.addEventListener('message', (evt) => {
|
|
52
|
+
console.log(`${evt.detail.topic}:`, new TextDecoder().decode(evt.detail.data))
|
|
44
53
|
})
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
node.services.pubsub.subscribe('fruit')
|
|
56
|
+
|
|
57
|
+
node.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
# Install
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
```console
|
|
63
|
+
$ npm i @libp2p/gossipsub
|
|
49
64
|
```
|
|
50
65
|
|
|
51
|
-
##
|
|
66
|
+
## Browser `<script>` tag
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
Loading this module through a script tag will make its exports available as `Libp2pGossipsub` in the global namespace.
|
|
54
69
|
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
const gossipsub = gossipsub(options)(libp2p)
|
|
70
|
+
```html
|
|
71
|
+
<script src="https://unpkg.com/@libp2p/gossipsub/dist/index.min.js"></script>
|
|
58
72
|
```
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
# API Docs
|
|
61
75
|
|
|
62
|
-
-
|
|
63
|
-
- **`gossipIncoming`**: boolean identifying if incoming messages on a subscribed topic should be automatically gossiped (defaults to **true**).
|
|
64
|
-
- **`fallbackToFloodsub`**: boolean identifying whether the node should fallback to the floodsub protocol, if another connecting peer does not support gossipsub (defaults to **true**).
|
|
65
|
-
- **`floodPublish`**: boolean identifying if self-published messages should be sent to all peers, (defaults to **true**).
|
|
66
|
-
- **`doPX`**: boolean identifying whether PX is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes (defaults to **false**).
|
|
67
|
-
- **`msgIdFn`**: a function with signature `(message) => string` defining the message id given a message, used internally to deduplicate gossip (defaults to `(message) => message.from + message.seqno.toString('hex')`)
|
|
68
|
-
- **`signMessages`**: boolean identifying if we want to sign outgoing messages or not (default: `true`)
|
|
69
|
-
- **`strictSigning`**: boolean identifying if message signing is required for incoming messages or not (default: `true`)
|
|
70
|
-
- **`messageCache`**: optional, a customized `MessageCache` instance, see the implementation for the interface.
|
|
71
|
-
- **`scoreParams`**: optional, a customized peer score parameters Object.
|
|
72
|
-
- **`scoreThresholds`**: optional, a customized peer score thresholds Object.
|
|
73
|
-
- **`directPeers`**: optional, an array of `AddrInfo` of peers with which we will maintain direct connections.
|
|
76
|
+
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_gossipsub.html>
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
# License
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
Licensed under either of
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/gossipsub/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
83
|
+
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/gossipsub/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
# Contribution
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
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.
|