@libp2p/bootstrap 9.0.8 → 9.0.9-69581367
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 +21 -42
- package/dist/src/index.d.ts +48 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +50 -2
- package/dist/src/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +51 -2
- package/dist/typedoc-urls.json +0 -8
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# @libp2p/bootstrap <!-- omit in toc -->
|
|
2
|
-
|
|
3
1
|
[](http://libp2p.io/)
|
|
4
2
|
[](https://discuss.libp2p.io)
|
|
5
3
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
@@ -7,37 +5,11 @@
|
|
|
7
5
|
|
|
8
6
|
> Peer discovery via a list of bootstrap peers
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [API Docs](#api-docs)
|
|
16
|
-
- [License](#license)
|
|
17
|
-
- [Contribution](#contribution)
|
|
18
|
-
|
|
19
|
-
## Install
|
|
20
|
-
|
|
21
|
-
```console
|
|
22
|
-
$ npm i @libp2p/bootstrap
|
|
23
|
-
```
|
|
8
|
+
# About
|
|
24
9
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Loading this module through a script tag will make it's exports available as `Libp2pBootstrap` in the global namespace.
|
|
28
|
-
|
|
29
|
-
```html
|
|
30
|
-
<script src="https://unpkg.com/@libp2p/bootstrap/dist/index.min.js"></script>
|
|
31
|
-
```
|
|
10
|
+
The configured bootstrap peers will be discovered after the configured timeout. This will ensure there are some peers in the peer store for the node to use to discover other peers.
|
|
32
11
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
The configured bootstrap peers will be discovered after the configured timeout. This will ensure
|
|
36
|
-
there are some peers in the peer store for the node to use to discover other peers.
|
|
37
|
-
|
|
38
|
-
They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire
|
|
39
|
-
after two minutes which means the nodes connections may be closed if the maximum number of
|
|
40
|
-
connections is reached.
|
|
12
|
+
They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire after two minutes which means the nodes connections may be closed if the maximum number of connections is reached.
|
|
41
13
|
|
|
42
14
|
Clients that need constant connections to bootstrap nodes (e.g. browsers) can set the TTL to `Infinity`.
|
|
43
15
|
|
|
@@ -73,31 +45,38 @@ let options = {
|
|
|
73
45
|
]
|
|
74
46
|
}
|
|
75
47
|
|
|
76
|
-
|
|
77
|
-
let libp2p = await createLibp2p(options)
|
|
48
|
+
const libp2p = await createLibp2p(options)
|
|
78
49
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
50
|
+
libp2p.on('peer:discovery', function (peerId) {
|
|
51
|
+
console.log('found peer: ', peerId.toB58String())
|
|
52
|
+
})
|
|
53
|
+
```
|
|
82
54
|
|
|
83
|
-
|
|
55
|
+
# Install
|
|
84
56
|
|
|
85
|
-
|
|
57
|
+
```console
|
|
58
|
+
$ npm i @libp2p/bootstrap
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Browser `<script>` tag
|
|
62
|
+
|
|
63
|
+
Loading this module through a script tag will make it's exports available as `Libp2pBootstrap` in the global namespace.
|
|
86
64
|
|
|
87
|
-
|
|
65
|
+
```html
|
|
66
|
+
<script src="https://unpkg.com/@libp2p/bootstrap/dist/index.min.js"></script>
|
|
88
67
|
```
|
|
89
68
|
|
|
90
|
-
|
|
69
|
+
# API Docs
|
|
91
70
|
|
|
92
71
|
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_bootstrap.html>
|
|
93
72
|
|
|
94
|
-
|
|
73
|
+
# License
|
|
95
74
|
|
|
96
75
|
Licensed under either of
|
|
97
76
|
|
|
98
77
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
99
78
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
100
79
|
|
|
101
|
-
|
|
80
|
+
# Contribution
|
|
102
81
|
|
|
103
82
|
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,3 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* The configured bootstrap peers will be discovered after the configured timeout. This will ensure there are some peers in the peer store for the node to use to discover other peers.
|
|
5
|
+
*
|
|
6
|
+
* They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire after two minutes which means the nodes connections may be closed if the maximum number of connections is reached.
|
|
7
|
+
*
|
|
8
|
+
* Clients that need constant connections to bootstrap nodes (e.g. browsers) can set the TTL to `Infinity`.
|
|
9
|
+
*
|
|
10
|
+
* ```JavaScript
|
|
11
|
+
* import { createLibp2p } from 'libp2p'
|
|
12
|
+
* import { bootstrap } from '@libp2p/bootstrap'
|
|
13
|
+
* import { tcp } from 'libp2p/tcp'
|
|
14
|
+
* import { noise } from '@libp2p/noise'
|
|
15
|
+
* import { mplex } from '@libp2p/mplex'
|
|
16
|
+
*
|
|
17
|
+
* let options = {
|
|
18
|
+
* transports: [
|
|
19
|
+
* tcp()
|
|
20
|
+
* ],
|
|
21
|
+
* streamMuxers: [
|
|
22
|
+
* mplex()
|
|
23
|
+
* ],
|
|
24
|
+
* connectionEncryption: [
|
|
25
|
+
* noise()
|
|
26
|
+
* ],
|
|
27
|
+
* peerDiscovery: [
|
|
28
|
+
* bootstrap({
|
|
29
|
+
* list: [ // a list of bootstrap peer multiaddrs to connect to on node startup
|
|
30
|
+
* "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
31
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
32
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
|
|
33
|
+
* ],
|
|
34
|
+
* timeout: 1000, // in ms,
|
|
35
|
+
* tagName: 'bootstrap',
|
|
36
|
+
* tagValue: 50,
|
|
37
|
+
* tagTTL: 120000 // in ms
|
|
38
|
+
* })
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* const libp2p = await createLibp2p(options)
|
|
43
|
+
*
|
|
44
|
+
* libp2p.on('peer:discovery', function (peerId) {
|
|
45
|
+
* console.log('found peer: ', peerId.toB58String())
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
1
49
|
import type { PeerDiscovery } from '@libp2p/interface/peer-discovery';
|
|
2
50
|
import type { PeerStore } from '@libp2p/interface/peer-store';
|
|
3
51
|
export interface BootstrapInit {
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,kCAAkC,CAAA;AAE1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAU7D,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,SAAS,CAAA;CACrB;AAkHD,wBAAgB,SAAS,CAAE,IAAI,EAAE,aAAa,GAAG,CAAC,UAAU,EAAE,mBAAmB,KAAK,aAAa,CAElG"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* The configured bootstrap peers will be discovered after the configured timeout. This will ensure there are some peers in the peer store for the node to use to discover other peers.
|
|
5
|
+
*
|
|
6
|
+
* They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire after two minutes which means the nodes connections may be closed if the maximum number of connections is reached.
|
|
7
|
+
*
|
|
8
|
+
* Clients that need constant connections to bootstrap nodes (e.g. browsers) can set the TTL to `Infinity`.
|
|
9
|
+
*
|
|
10
|
+
* ```JavaScript
|
|
11
|
+
* import { createLibp2p } from 'libp2p'
|
|
12
|
+
* import { bootstrap } from '@libp2p/bootstrap'
|
|
13
|
+
* import { tcp } from 'libp2p/tcp'
|
|
14
|
+
* import { noise } from '@libp2p/noise'
|
|
15
|
+
* import { mplex } from '@libp2p/mplex'
|
|
16
|
+
*
|
|
17
|
+
* let options = {
|
|
18
|
+
* transports: [
|
|
19
|
+
* tcp()
|
|
20
|
+
* ],
|
|
21
|
+
* streamMuxers: [
|
|
22
|
+
* mplex()
|
|
23
|
+
* ],
|
|
24
|
+
* connectionEncryption: [
|
|
25
|
+
* noise()
|
|
26
|
+
* ],
|
|
27
|
+
* peerDiscovery: [
|
|
28
|
+
* bootstrap({
|
|
29
|
+
* list: [ // a list of bootstrap peer multiaddrs to connect to on node startup
|
|
30
|
+
* "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
31
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
32
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
|
|
33
|
+
* ],
|
|
34
|
+
* timeout: 1000, // in ms,
|
|
35
|
+
* tagName: 'bootstrap',
|
|
36
|
+
* tagValue: 50,
|
|
37
|
+
* tagTTL: 120000 // in ms
|
|
38
|
+
* })
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* const libp2p = await createLibp2p(options)
|
|
43
|
+
*
|
|
44
|
+
* libp2p.on('peer:discovery', function (peerId) {
|
|
45
|
+
* console.log('found peer: ', peerId.toB58String())
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
import { TypedEventEmitter } from '@libp2p/interface/events';
|
|
2
50
|
import { peerDiscovery } from '@libp2p/interface/peer-discovery';
|
|
3
51
|
import { logger } from '@libp2p/logger';
|
|
4
52
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
@@ -12,7 +60,7 @@ const DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT = 1000;
|
|
|
12
60
|
/**
|
|
13
61
|
* Emits 'peer' events on a regular interval for each peer in the provided list.
|
|
14
62
|
*/
|
|
15
|
-
class Bootstrap extends
|
|
63
|
+
class Bootstrap extends TypedEventEmitter {
|
|
16
64
|
static tag = 'bootstrap';
|
|
17
65
|
timer;
|
|
18
66
|
list;
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceR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;;OAEG;IACH,KAAK,CAAC,uBAAuB;QAC3B,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;YACtB,OAAM;SACP;QAED,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE;YAChC,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE;gBACjD,IAAI,EAAE;oBACJ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,0BAA0B,CAAC,EAAE;wBAClD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,2BAA2B;wBACzD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,yBAAyB;qBACpD;iBACF;aACF,CAAC,CAAA;YAEF,6BAA6B;YAC7B,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;gBACtB,OAAM;aACP;YAED,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;SACrD;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE;YACtB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;SACzB;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;IACxB,CAAC;;AAGH,MAAM,UAAU,SAAS,CAAE,IAAmB;IAC5C,OAAO,CAAC,UAA+B,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC7E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.9-69581367",
|
|
4
4
|
"description": "Peer discovery via a list of bootstrap peers",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/peer-discovery-bootstrap#readme",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"test:electron-main": "aegir test -t electron-main"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@libp2p/interface": "
|
|
53
|
-
"@libp2p/logger": "
|
|
54
|
-
"@libp2p/peer-id": "
|
|
52
|
+
"@libp2p/interface": "0.1.4-69581367",
|
|
53
|
+
"@libp2p/logger": "3.0.4-69581367",
|
|
54
|
+
"@libp2p/peer-id": "3.0.4-69581367",
|
|
55
55
|
"@multiformats/mafmt": "^12.1.2",
|
|
56
56
|
"@multiformats/multiaddr": "^12.1.5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@libp2p/interface-compliance-tests": "
|
|
59
|
+
"@libp2p/interface-compliance-tests": "4.1.2-69581367",
|
|
60
60
|
"aegir": "^41.0.2",
|
|
61
61
|
"sinon-ts": "^1.0.0"
|
|
62
62
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* The configured bootstrap peers will be discovered after the configured timeout. This will ensure there are some peers in the peer store for the node to use to discover other peers.
|
|
5
|
+
*
|
|
6
|
+
* They will be tagged with a tag with the name `'bootstrap'` tag, the value `50` and it will expire after two minutes which means the nodes connections may be closed if the maximum number of connections is reached.
|
|
7
|
+
*
|
|
8
|
+
* Clients that need constant connections to bootstrap nodes (e.g. browsers) can set the TTL to `Infinity`.
|
|
9
|
+
*
|
|
10
|
+
* ```JavaScript
|
|
11
|
+
* import { createLibp2p } from 'libp2p'
|
|
12
|
+
* import { bootstrap } from '@libp2p/bootstrap'
|
|
13
|
+
* import { tcp } from 'libp2p/tcp'
|
|
14
|
+
* import { noise } from '@libp2p/noise'
|
|
15
|
+
* import { mplex } from '@libp2p/mplex'
|
|
16
|
+
*
|
|
17
|
+
* let options = {
|
|
18
|
+
* transports: [
|
|
19
|
+
* tcp()
|
|
20
|
+
* ],
|
|
21
|
+
* streamMuxers: [
|
|
22
|
+
* mplex()
|
|
23
|
+
* ],
|
|
24
|
+
* connectionEncryption: [
|
|
25
|
+
* noise()
|
|
26
|
+
* ],
|
|
27
|
+
* peerDiscovery: [
|
|
28
|
+
* bootstrap({
|
|
29
|
+
* list: [ // a list of bootstrap peer multiaddrs to connect to on node startup
|
|
30
|
+
* "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
31
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
32
|
+
* "/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
|
|
33
|
+
* ],
|
|
34
|
+
* timeout: 1000, // in ms,
|
|
35
|
+
* tagName: 'bootstrap',
|
|
36
|
+
* tagValue: 50,
|
|
37
|
+
* tagTTL: 120000 // in ms
|
|
38
|
+
* })
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* const libp2p = await createLibp2p(options)
|
|
43
|
+
*
|
|
44
|
+
* libp2p.on('peer:discovery', function (peerId) {
|
|
45
|
+
* console.log('found peer: ', peerId.toB58String())
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
import { TypedEventEmitter } from '@libp2p/interface/events'
|
|
2
51
|
import { peerDiscovery } from '@libp2p/interface/peer-discovery'
|
|
3
52
|
import { logger } from '@libp2p/logger'
|
|
4
53
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
@@ -50,7 +99,7 @@ export interface BootstrapComponents {
|
|
|
50
99
|
/**
|
|
51
100
|
* Emits 'peer' events on a regular interval for each peer in the provided list.
|
|
52
101
|
*/
|
|
53
|
-
class Bootstrap extends
|
|
102
|
+
class Bootstrap extends TypedEventEmitter<PeerDiscoveryEvents> implements PeerDiscovery, Startable {
|
|
54
103
|
static tag = 'bootstrap'
|
|
55
104
|
|
|
56
105
|
private timer?: ReturnType<typeof setTimeout>
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
3
|
-
".:BootstrapComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapComponents.html",
|
|
4
|
-
"BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
5
|
-
".:BootstrapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_bootstrap.BootstrapInit.html",
|
|
6
|
-
"bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html",
|
|
7
|
-
".:bootstrap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_bootstrap.bootstrap.html"
|
|
8
|
-
}
|