@libp2p/bootstrap 11.0.47 → 12.0.0-049bfa0fa
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.js +15 -13
- package/dist/src/index.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +25 -25
- package/dist/typedoc-urls.json +0 -8
package/dist/src/index.js
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { peerDiscoverySymbol, serviceCapabilities } from '@libp2p/interface';
|
|
35
35
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
36
|
+
import { CODE_P2P, multiaddr } from '@multiformats/multiaddr';
|
|
37
|
+
import { P2P } from '@multiformats/multiaddr-matcher';
|
|
38
38
|
import { TypedEventEmitter } from 'main-event';
|
|
39
39
|
const DEFAULT_BOOTSTRAP_TAG_NAME = 'bootstrap';
|
|
40
40
|
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50;
|
|
@@ -58,24 +58,26 @@ class Bootstrap extends TypedEventEmitter {
|
|
|
58
58
|
this.components = components;
|
|
59
59
|
this.log = components.logger.forComponent('libp2p:bootstrap');
|
|
60
60
|
this.timeout = options.timeout ?? DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT;
|
|
61
|
-
this.list =
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
this.list = options.list
|
|
62
|
+
.map(str => multiaddr(str))
|
|
63
|
+
.filter(ma => {
|
|
64
|
+
if (!P2P.matches(ma)) {
|
|
64
65
|
this.log.error('Invalid multiaddr');
|
|
65
|
-
|
|
66
|
+
return false;
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
const peerIdStr = ma.getPeerId();
|
|
68
|
+
const peerIdStr = ma.getComponents().findLast(c => c.code === CODE_P2P)?.value;
|
|
69
69
|
if (peerIdStr == null) {
|
|
70
70
|
this.log.error('Invalid bootstrap multiaddr without peer id');
|
|
71
|
-
|
|
71
|
+
return false;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
return true;
|
|
74
|
+
})
|
|
75
|
+
.map(ma => {
|
|
76
|
+
return {
|
|
77
|
+
id: peerIdFromString(ma.getComponents().findLast(c => c.code === CODE_P2P)?.value ?? ''),
|
|
75
78
|
multiaddrs: [ma]
|
|
76
79
|
};
|
|
77
|
-
|
|
78
|
-
}
|
|
80
|
+
});
|
|
79
81
|
this._init = options;
|
|
80
82
|
}
|
|
81
83
|
[peerDiscoverySymbol] = this;
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAI9C,MAAM,0BAA0B,GAAG,WAAW,CAAA;AAC9C,MAAM,2BAA2B,GAAG,EAAE,CAAA;AACtC,MAAM,mCAAmC,GAAG,IAAI,CAAA;AAuChD;;G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2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0-049bfa0fa",
|
|
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/main/packages/peer-discovery-bootstrap#readme",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"test:electron-main": "aegir test -t electron-main"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@libp2p/interface": "
|
|
51
|
-
"@libp2p/interface-internal": "
|
|
52
|
-
"@libp2p/peer-id": "
|
|
53
|
-
"@multiformats/
|
|
54
|
-
"@multiformats/multiaddr": "^
|
|
50
|
+
"@libp2p/interface": "3.0.0-049bfa0fa",
|
|
51
|
+
"@libp2p/interface-internal": "3.0.0-049bfa0fa",
|
|
52
|
+
"@libp2p/peer-id": "6.0.0-049bfa0fa",
|
|
53
|
+
"@multiformats/multiaddr": "^13.0.1",
|
|
54
|
+
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
55
55
|
"main-event": "^1.0.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@libp2p/interface-compliance-tests": "
|
|
59
|
-
"@libp2p/logger": "
|
|
60
|
-
"aegir": "^47.0.
|
|
58
|
+
"@libp2p/interface-compliance-tests": "7.0.0-049bfa0fa",
|
|
59
|
+
"@libp2p/logger": "6.0.0-049bfa0fa",
|
|
60
|
+
"aegir": "^47.0.22",
|
|
61
61
|
"sinon-ts": "^2.0.0"
|
|
62
62
|
},
|
|
63
63
|
"sideEffects": false
|
package/src/index.ts
CHANGED
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
|
|
35
35
|
import { peerDiscoverySymbol, serviceCapabilities } from '@libp2p/interface'
|
|
36
36
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
37
|
+
import { CODE_P2P, multiaddr } from '@multiformats/multiaddr'
|
|
38
|
+
import { P2P } from '@multiformats/multiaddr-matcher'
|
|
39
39
|
import { TypedEventEmitter } from 'main-event'
|
|
40
40
|
import type { ComponentLogger, Logger, PeerDiscovery, PeerDiscoveryEvents, PeerInfo, PeerStore, Startable } from '@libp2p/interface'
|
|
41
41
|
import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
@@ -103,29 +103,29 @@ class Bootstrap extends TypedEventEmitter<PeerDiscoveryEvents> implements PeerDi
|
|
|
103
103
|
this.components = components
|
|
104
104
|
this.log = components.logger.forComponent('libp2p:bootstrap')
|
|
105
105
|
this.timeout = options.timeout ?? DEFAULT_BOOTSTRAP_DISCOVERY_TIMEOUT
|
|
106
|
-
this.list =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
106
|
+
this.list = options.list
|
|
107
|
+
.map(str => multiaddr(str))
|
|
108
|
+
.filter(ma => {
|
|
109
|
+
if (!P2P.matches(ma)) {
|
|
110
|
+
this.log.error('Invalid multiaddr')
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const peerIdStr = ma.getComponents().findLast(c => c.code === CODE_P2P)?.value
|
|
115
|
+
|
|
116
|
+
if (peerIdStr == null) {
|
|
117
|
+
this.log.error('Invalid bootstrap multiaddr without peer id')
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return true
|
|
122
|
+
})
|
|
123
|
+
.map(ma => {
|
|
124
|
+
return {
|
|
125
|
+
id: peerIdFromString(ma.getComponents().findLast(c => c.code === CODE_P2P)?.value ?? ''),
|
|
126
|
+
multiaddrs: [ma]
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
129
|
|
|
130
130
|
this._init = options
|
|
131
131
|
}
|
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
|
-
}
|