@libp2p/peer-store 2.0.0 → 3.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 +25 -14
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @libp2p/peer-store <!-- omit in toc -->
|
|
2
2
|
|
|
3
|
-
[](http://libp2p.io/)
|
|
4
|
+
[](http://webchat.freenode.net/?channels=%23libp2p)
|
|
5
|
+
[](https://discuss.libp2p.io)
|
|
6
|
+
[](https://codecov.io/gh/libp2p/js-libp2p-peer-store)
|
|
7
|
+
[](https://github.com/libp2p/js-libp2p-peer-store/actions/workflows/js-test-and-release.yml)
|
|
4
8
|
|
|
5
9
|
> Stores information about peers libp2p knows on the network
|
|
6
10
|
|
|
7
|
-
## Table of
|
|
11
|
+
## Table of contents <!-- omit in toc -->
|
|
8
12
|
|
|
13
|
+
- [Install](#install)
|
|
9
14
|
- [Description](#description)
|
|
10
15
|
- [Submitting records to the PeerStore](#submitting-records-to-the-peerstore)
|
|
11
16
|
- [Identify](#identify)
|
|
@@ -26,9 +31,14 @@
|
|
|
26
31
|
- [Events](#events)
|
|
27
32
|
- [Data Persistence](#data-persistence)
|
|
28
33
|
- [Future Considerations](#future-considerations)
|
|
29
|
-
- [Installation](#installation)
|
|
30
34
|
- [License](#license)
|
|
31
|
-
|
|
35
|
+
- [Contribution](#contribution)
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```console
|
|
40
|
+
$ npm i @libp2p/peer-store
|
|
41
|
+
```
|
|
32
42
|
|
|
33
43
|
## Description
|
|
34
44
|
|
|
@@ -41,19 +51,23 @@ The PeerStore manages the high level operations on its inner books. Moreover, th
|
|
|
41
51
|
Several libp2p subsystems will perform operations that might gather relevant information about peers.
|
|
42
52
|
|
|
43
53
|
#### Identify
|
|
54
|
+
|
|
44
55
|
- The Identify protocol automatically runs on every connection when multiplexing is enabled. The protocol will put the multiaddrs and protocols provided by the peer to the PeerStore.
|
|
45
56
|
- In the background, the Identify Service is also waiting for protocol change notifications of peers via the IdentifyPush protocol. Peers may leverage the `identify-push` message to communicate protocol changes to all connected peers, so that their PeerStore can be updated with the updated protocols.
|
|
46
57
|
- While it is currently not supported in js-libp2p, future iterations may also support the [IdentifyDelta protocol](https://github.com/libp2p/specs/pull/176).
|
|
47
58
|
- Taking into account that the Identify protocol records are directly from the peer, they should be considered the source of truth and weighted accordingly.
|
|
48
59
|
|
|
49
60
|
#### Peer Discovery
|
|
61
|
+
|
|
50
62
|
- Libp2p discovery protocols aim to discover new peers in the network. In a typical discovery protocol, addresses of the peer are discovered along with its peer id. Once this happens, a libp2p discovery protocol should emit a `peer` event with the information of the discovered peer and this information will be added to the PeerStore by libp2p.
|
|
51
63
|
|
|
52
64
|
#### Dialer
|
|
65
|
+
|
|
53
66
|
- Libp2p API supports dialing a peer given a `multiaddr`, and no prior knowledge of the peer. If the node is able to establish a connection with the peer, it and its multiaddr is added to the PeerStore.
|
|
54
67
|
- When a connection is being upgraded, more precisely after its encryption, or even in a discovery protocol, a libp2p node can get to know other parties public keys. In this scenario, libp2p will add the peer's public key to its `KeyBook`.
|
|
55
68
|
|
|
56
69
|
#### DHT
|
|
70
|
+
|
|
57
71
|
- On some DHT operations, such as finding providers for a given CID, nodes may exchange peer data as part of the query. This passive peer discovery should result in the DHT emitting the `peer` event in the same way [Peer Discovery](#peerdiscovery) does.
|
|
58
72
|
|
|
59
73
|
### Retrieving records from the PeerStore
|
|
@@ -61,12 +75,15 @@ Several libp2p subsystems will perform operations that might gather relevant inf
|
|
|
61
75
|
When data in the PeerStore is updated the PeerStore will emit events based on the changes, to allow applications and other subsystems to take action on those changes. Any subsystem interested in these notifications should subscribe the [`PeerStore events`][peer-store-events].
|
|
62
76
|
|
|
63
77
|
#### Peer
|
|
78
|
+
|
|
64
79
|
- Each time a new peer is discovered, the PeerStore should emit a [`peer` event][peer-store-events], so that interested parties can leverage this peer and establish a connection with it.
|
|
65
80
|
|
|
66
81
|
#### Protocols
|
|
82
|
+
|
|
67
83
|
- When the known protocols of a peer change, the PeerStore emits a [`change:protocols` event][peer-store-events].
|
|
68
84
|
|
|
69
85
|
#### Multiaddrs
|
|
86
|
+
|
|
70
87
|
- When the known listening `multiaddrs` of a peer change, the PeerStore emits a [`change:multiaddrs` event][peer-store-events].
|
|
71
88
|
|
|
72
89
|
### PeerStore implementation
|
|
@@ -173,20 +190,14 @@ Metadata is stored under the following key pattern:
|
|
|
173
190
|
- When improving libp2p configuration for specific runtimes, we should take into account the PeerStore recommended datastore.
|
|
174
191
|
- When improving libp2p configuration, we should think about a possible way of allowing the configuration of Bootstrap to be influenced by the persisted peers, as a way to decrease the load on Bootstrap nodes.
|
|
175
192
|
|
|
176
|
-
## Installation
|
|
177
|
-
|
|
178
|
-
```console
|
|
179
|
-
$ npm i @libp2p/tracked-map
|
|
180
|
-
```
|
|
181
|
-
|
|
182
193
|
## License
|
|
183
194
|
|
|
184
195
|
Licensed under either of
|
|
185
196
|
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
198
|
+
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
188
199
|
|
|
189
|
-
|
|
200
|
+
## Contribution
|
|
190
201
|
|
|
191
202
|
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.
|
|
192
203
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/peer-store",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Stores information about peers libp2p knows on the network",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-peer-store#readme",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
+
"types": "./src/index.d.ts",
|
|
31
32
|
"import": "./dist/src/index.js"
|
|
32
33
|
}
|
|
33
34
|
},
|
|
@@ -138,13 +139,13 @@
|
|
|
138
139
|
"release": "aegir release"
|
|
139
140
|
},
|
|
140
141
|
"dependencies": {
|
|
141
|
-
"@libp2p/components": "^
|
|
142
|
+
"@libp2p/components": "^2.0.0",
|
|
142
143
|
"@libp2p/interface-peer-id": "^1.0.2",
|
|
143
144
|
"@libp2p/interface-peer-info": "^1.0.1",
|
|
144
145
|
"@libp2p/interface-peer-store": "^1.0.0",
|
|
145
146
|
"@libp2p/interface-record": "^1.0.1",
|
|
146
147
|
"@libp2p/interfaces": "^3.0.2",
|
|
147
|
-
"@libp2p/logger": "^
|
|
148
|
+
"@libp2p/logger": "^2.0.0",
|
|
148
149
|
"@libp2p/peer-id": "^1.1.0",
|
|
149
150
|
"@libp2p/peer-record": "^2.0.0",
|
|
150
151
|
"@multiformats/multiaddr": "^10.2.0",
|
|
@@ -161,10 +162,10 @@
|
|
|
161
162
|
"uint8arrays": "^3.0.0"
|
|
162
163
|
},
|
|
163
164
|
"devDependencies": {
|
|
164
|
-
"@libp2p/interface-compliance-tests": "^
|
|
165
|
+
"@libp2p/interface-compliance-tests": "^3.0.1",
|
|
165
166
|
"@libp2p/peer-id-factory": "^1.0.0",
|
|
166
|
-
"@libp2p/utils": "^
|
|
167
|
-
"aegir": "^37.0
|
|
167
|
+
"@libp2p/utils": "^2.0.0",
|
|
168
|
+
"aegir": "^37.3.0",
|
|
168
169
|
"datastore-core": "^7.0.1",
|
|
169
170
|
"p-defer": "^4.0.0",
|
|
170
171
|
"p-wait-for": "^4.1.0",
|