@libp2p/bootstrap 1.0.0 → 1.0.3
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/src/index.d.ts +3 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -8
- package/dist/src/index.js.map +1 -1
- package/package.json +18 -19
- package/src/index.ts +12 -14
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import type PeerDiscovery from '@libp2p/interfaces/peer-discovery';
|
|
1
|
+
import { EventEmitter } from '@libp2p/interfaces';
|
|
2
|
+
import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery';
|
|
4
3
|
export interface BootstrapOptions {
|
|
5
4
|
/**
|
|
6
5
|
* The list of peer addresses in multi-address format
|
|
@@ -14,7 +13,7 @@ export interface BootstrapOptions {
|
|
|
14
13
|
/**
|
|
15
14
|
* Emits 'peer' events on a regular interval for each peer in the provided list.
|
|
16
15
|
*/
|
|
17
|
-
export declare class Bootstrap extends EventEmitter implements PeerDiscovery {
|
|
16
|
+
export declare class Bootstrap extends EventEmitter<PeerDiscoveryEvents> implements PeerDiscovery {
|
|
18
17
|
static tag: string;
|
|
19
18
|
private timer?;
|
|
20
19
|
private readonly list;
|
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":"AAEA,OAAO,EAAe,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAM3F,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;IAEd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY,CAAC,mBAAmB,CAAE,YAAW,aAAa;IACvF,MAAM,CAAC,GAAG,SAAc;IAExB,OAAO,CAAC,KAAK,CAAC,CAAgC;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAEpB,OAAO,GAAE,gBAA+B;IAiCrD,SAAS;IAIT;;OAEG;IACH,KAAK;IAUL;;OAEG;IACH,uBAAuB;IAUvB;;OAEG;IACH,IAAI;CAOL"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { PeerId } from '@libp2p/peer-id';
|
|
2
1
|
import { Multiaddr } from '@multiformats/multiaddr';
|
|
3
2
|
import { P2P } from '@multiformats/mafmt';
|
|
4
|
-
import { EventEmitter } from '
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
3
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interfaces';
|
|
4
|
+
import { logger } from '@libp2p/logger';
|
|
5
|
+
import { peerIdFromString } from '@libp2p/peer-id';
|
|
6
|
+
const log = logger('libp2p:bootstrap');
|
|
9
7
|
/**
|
|
10
8
|
* Emits 'peer' events on a regular interval for each peer in the provided list.
|
|
11
9
|
*/
|
|
@@ -29,7 +27,7 @@ export class Bootstrap extends EventEmitter {
|
|
|
29
27
|
continue;
|
|
30
28
|
}
|
|
31
29
|
const peerData = {
|
|
32
|
-
id:
|
|
30
|
+
id: peerIdFromString(peerIdStr),
|
|
33
31
|
multiaddrs: [ma],
|
|
34
32
|
protocols: []
|
|
35
33
|
};
|
|
@@ -58,7 +56,7 @@ export class Bootstrap extends EventEmitter {
|
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
60
58
|
this.list.forEach((peerData) => {
|
|
61
|
-
this.
|
|
59
|
+
this.dispatchEvent(new CustomEvent('peer', { detail: peerData }));
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
/**
|
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","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AActC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,YAAiC;IAO9D,YAAa,UAA4B,EAAE,IAAI,EAAE,EAAE,EAAE;QACnD,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;QACD,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAA;QACzC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;QAEd,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE;YACpC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBAC3B,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;gBAC9B,SAAQ;aACT;YAED,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,S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AG,SAAS,CAAA;IACxB,CAAC;;AA9EM,aAAG,GAAG,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/bootstrap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Node.js IPFS Implementation of the railing process of a Node through a bootstrap peer list",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p-bootstrap#readme",
|
|
@@ -119,29 +119,28 @@
|
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|
|
122
|
+
"clean": "aegir clean",
|
|
122
123
|
"lint": "aegir lint",
|
|
123
|
-
"dep-check": "aegir dep-check
|
|
124
|
-
"build": "
|
|
125
|
-
"
|
|
126
|
-
"test": "aegir test -
|
|
127
|
-
"test:chrome": "
|
|
128
|
-
"test:
|
|
129
|
-
"test:firefox": "
|
|
130
|
-
"test:
|
|
131
|
-
"test:
|
|
132
|
-
"
|
|
133
|
-
"release": "semantic-release"
|
|
124
|
+
"dep-check": "aegir dep-check",
|
|
125
|
+
"build": "aegir build",
|
|
126
|
+
"test": "aegir test",
|
|
127
|
+
"test:chrome": "aegir test -t browser --cov",
|
|
128
|
+
"test:chrome-webworker": "aegir test -t webworker",
|
|
129
|
+
"test:firefox": "aegir test -t browser -- --browser firefox",
|
|
130
|
+
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
|
|
131
|
+
"test:node": "aegir test -t node --cov",
|
|
132
|
+
"test:electron-main": "aegir test -t electron-main",
|
|
133
|
+
"release": "aegir release"
|
|
134
134
|
},
|
|
135
135
|
"dependencies": {
|
|
136
|
-
"@libp2p/
|
|
136
|
+
"@libp2p/interfaces": "^1.3.20",
|
|
137
|
+
"@libp2p/logger": "^1.1.3",
|
|
138
|
+
"@libp2p/peer-id": "^1.1.9",
|
|
137
139
|
"@multiformats/mafmt": "^11.0.2",
|
|
138
|
-
"@multiformats/multiaddr": "^10.1.
|
|
139
|
-
"debug": "^4.3.1"
|
|
140
|
+
"@multiformats/multiaddr": "^10.1.7"
|
|
140
141
|
},
|
|
141
142
|
"devDependencies": {
|
|
142
|
-
"@libp2p/interface-compliance-tests": "^1.
|
|
143
|
-
"
|
|
144
|
-
"@types/debug": "^4.1.5",
|
|
145
|
-
"aegir": "^36.1.3"
|
|
143
|
+
"@libp2p/interface-compliance-tests": "^1.1.21",
|
|
144
|
+
"aegir": "^37.0.7"
|
|
146
145
|
}
|
|
147
146
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { PeerId } from '@libp2p/peer-id'
|
|
2
1
|
import { Multiaddr } from '@multiformats/multiaddr'
|
|
3
2
|
import { P2P } from '@multiformats/mafmt'
|
|
4
|
-
import { EventEmitter } from '
|
|
5
|
-
import
|
|
6
|
-
import type PeerDiscovery from '@libp2p/interfaces/peer-discovery'
|
|
7
|
-
import type {
|
|
3
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interfaces'
|
|
4
|
+
import { logger } from '@libp2p/logger'
|
|
5
|
+
import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery'
|
|
6
|
+
import type { PeerInfo } from '@libp2p/interfaces/peer-info'
|
|
7
|
+
import { peerIdFromString } from '@libp2p/peer-id'
|
|
8
8
|
|
|
9
|
-
const log =
|
|
10
|
-
error: debug('libp2p:bootstrap:error')
|
|
11
|
-
})
|
|
9
|
+
const log = logger('libp2p:bootstrap')
|
|
12
10
|
|
|
13
11
|
export interface BootstrapOptions {
|
|
14
12
|
/**
|
|
@@ -25,11 +23,11 @@ export interface BootstrapOptions {
|
|
|
25
23
|
/**
|
|
26
24
|
* Emits 'peer' events on a regular interval for each peer in the provided list.
|
|
27
25
|
*/
|
|
28
|
-
export class Bootstrap extends EventEmitter implements PeerDiscovery {
|
|
26
|
+
export class Bootstrap extends EventEmitter<PeerDiscoveryEvents> implements PeerDiscovery {
|
|
29
27
|
static tag = 'bootstrap'
|
|
30
28
|
|
|
31
|
-
private timer?:
|
|
32
|
-
private readonly list:
|
|
29
|
+
private timer?: ReturnType<typeof setInterval>
|
|
30
|
+
private readonly list: PeerInfo[]
|
|
33
31
|
private readonly interval: number
|
|
34
32
|
|
|
35
33
|
constructor (options: BootstrapOptions = { list: [] }) {
|
|
@@ -55,8 +53,8 @@ export class Bootstrap extends EventEmitter implements PeerDiscovery {
|
|
|
55
53
|
continue
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
const peerData:
|
|
59
|
-
id:
|
|
56
|
+
const peerData: PeerInfo = {
|
|
57
|
+
id: peerIdFromString(peerIdStr),
|
|
60
58
|
multiaddrs: [ma],
|
|
61
59
|
protocols: []
|
|
62
60
|
}
|
|
@@ -91,7 +89,7 @@ export class Bootstrap extends EventEmitter implements PeerDiscovery {
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
this.list.forEach((peerData) => {
|
|
94
|
-
this.
|
|
92
|
+
this.dispatchEvent(new CustomEvent<PeerInfo>('peer', { detail: peerData }))
|
|
95
93
|
})
|
|
96
94
|
}
|
|
97
95
|
|