libp2p 0.35.8 → 0.36.0-d44bd90
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 +55 -0
- package/dist/src/circuit/auto-relay.d.ts +8 -10
- package/dist/src/circuit/auto-relay.d.ts.map +1 -1
- package/dist/src/config.d.ts +2 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dialler.d.ts +1 -1
- package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
- package/dist/src/connection-manager/index.d.ts +1 -2
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/content-routing/utils.d.ts +3 -3
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/dialer/dial-request.d.ts.map +1 -1
- package/dist/src/dialer/index.d.ts +12 -7
- package/dist/src/dialer/index.d.ts.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/fetch/constants.d.ts +2 -0
- package/dist/src/fetch/constants.d.ts.map +1 -0
- package/dist/src/fetch/index.d.ts +76 -0
- package/dist/src/fetch/index.d.ts.map +1 -0
- package/dist/src/fetch/proto.d.ts +134 -0
- package/dist/src/identify/index.d.ts +4 -4
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +26 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/metrics/index.d.ts +9 -4
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/metrics/tracked-map.d.ts +6 -1
- package/dist/src/metrics/tracked-map.d.ts.map +1 -1
- package/dist/src/peer-routing.d.ts +1 -1
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-store/address-book.d.ts +30 -84
- package/dist/src/peer-store/address-book.d.ts.map +1 -1
- package/dist/src/peer-store/index.d.ts +28 -94
- package/dist/src/peer-store/index.d.ts.map +1 -1
- package/dist/src/peer-store/key-book.d.ts +31 -15
- package/dist/src/peer-store/key-book.d.ts.map +1 -1
- package/dist/src/peer-store/metadata-book.d.ts +33 -29
- package/dist/src/peer-store/metadata-book.d.ts.map +1 -1
- package/dist/src/peer-store/pb/peer.d.ts +222 -0
- package/dist/src/peer-store/proto-book.d.ts +27 -28
- package/dist/src/peer-store/proto-book.d.ts.map +1 -1
- package/dist/src/peer-store/store.d.ts +73 -0
- package/dist/src/peer-store/store.d.ts.map +1 -0
- package/dist/src/peer-store/types.d.ts +202 -0
- package/dist/src/peer-store/types.d.ts.map +1 -0
- package/dist/src/ping/index.d.ts +32 -25
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/record/peer-record/index.d.ts +2 -2
- package/dist/src/record/peer-record/index.d.ts.map +1 -1
- package/dist/src/registrar.d.ts +5 -5
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/types.d.ts +90 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/upgrader.d.ts +8 -2
- package/dist/src/upgrader.d.ts.map +1 -1
- package/package.json +23 -26
- package/src/circuit/auto-relay.js +52 -38
- package/src/config.js +2 -0
- package/src/connection-manager/auto-dialler.js +20 -8
- package/src/connection-manager/index.js +42 -22
- package/src/content-routing/utils.js +4 -4
- package/src/dialer/dial-request.js +4 -1
- package/src/dialer/index.js +38 -8
- package/src/errors.js +2 -0
- package/src/fetch/README.md +36 -0
- package/src/fetch/constants.js +6 -0
- package/src/fetch/index.js +159 -0
- package/src/fetch/proto.d.ts +134 -0
- package/src/fetch/proto.js +333 -0
- package/src/fetch/proto.proto +15 -0
- package/src/identify/index.js +47 -38
- package/src/index.js +81 -34
- package/src/metrics/index.js +15 -8
- package/src/metrics/tracked-map.js +40 -14
- package/src/peer-routing.js +4 -1
- package/src/peer-store/address-book.js +254 -226
- package/src/peer-store/index.js +79 -110
- package/src/peer-store/key-book.js +99 -54
- package/src/peer-store/metadata-book.js +171 -101
- package/src/peer-store/pb/peer.d.ts +222 -0
- package/src/peer-store/pb/peer.js +643 -0
- package/src/peer-store/pb/peer.proto +31 -0
- package/src/peer-store/proto-book.js +171 -105
- package/src/peer-store/store.js +263 -0
- package/src/peer-store/types.ts +245 -0
- package/src/ping/index.js +51 -46
- package/src/record/peer-record/index.js +1 -1
- package/src/record/utils.js +1 -1
- package/src/registrar.js +4 -4
- package/src/types.ts +98 -0
- package/src/upgrader.js +32 -2
- package/dist/src/peer-store/book.d.ts +0 -81
- package/dist/src/peer-store/book.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/consts.d.ts +0 -6
- package/dist/src/peer-store/persistent/consts.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/index.d.ts +0 -129
- package/dist/src/peer-store/persistent/index.d.ts.map +0 -1
- package/dist/src/peer-store/persistent/pb/address-book.d.ts +0 -198
- package/dist/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
- package/src/peer-store/book.js +0 -124
- package/src/peer-store/persistent/consts.js +0 -15
- package/src/peer-store/persistent/index.js +0 -408
- package/src/peer-store/persistent/pb/address-book.d.ts +0 -198
- package/src/peer-store/persistent/pb/address-book.js +0 -522
- package/src/peer-store/persistent/pb/address-book.proto +0 -27
- package/src/peer-store/persistent/pb/proto-book.d.ts +0 -59
- package/src/peer-store/persistent/pb/proto-book.js +0 -157
- package/src/peer-store/persistent/pb/proto-book.proto +0 -5
|
@@ -45,7 +45,7 @@ declare class Metrics {
|
|
|
45
45
|
* @returns {void}
|
|
46
46
|
*/
|
|
47
47
|
private _onMessage;
|
|
48
|
-
|
|
48
|
+
_systems: Map<any, any>;
|
|
49
49
|
/**
|
|
50
50
|
* Must be called for stats to saved. Any data pushed for tracking
|
|
51
51
|
* will be ignored.
|
|
@@ -69,10 +69,15 @@ declare class Metrics {
|
|
|
69
69
|
*/
|
|
70
70
|
get peers(): string[];
|
|
71
71
|
/**
|
|
72
|
-
* @returns {Map}
|
|
72
|
+
* @returns {Map<string, Map<string, Map<string, any>>>}
|
|
73
73
|
*/
|
|
74
|
-
getComponentMetrics(): Map<
|
|
75
|
-
updateComponentMetric(
|
|
74
|
+
getComponentMetrics(): Map<string, Map<string, Map<string, any>>>;
|
|
75
|
+
updateComponentMetric({ system, component, metric, value }: {
|
|
76
|
+
system?: string | undefined;
|
|
77
|
+
component: any;
|
|
78
|
+
metric: any;
|
|
79
|
+
value: any;
|
|
80
|
+
}): void;
|
|
76
81
|
/**
|
|
77
82
|
* Returns the `Stats` object for the given `PeerId` whether it
|
|
78
83
|
* is a live peer, or in the disconnected peer LRU cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/index.js"],"names":[],"mappings":";AAoBA;;;GAGG;AAEH;;;;;;GAMG;AAEH;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metrics/index.js"],"names":[],"mappings":";AAoBA;;;GAGG;AAEH;;;;;;GAMG;AAEH;IA4OE;;;;;;;OAOG;IACH,0BAJW,KAAK,SACL,KAAK,GACH,KAAK,CAWjB;IA5PD;;;OAGG;IACH,qBAFW,cAAc,EAWxB;IARC,cAAqD;IACrD,oBAA6D;IAC7D,0BAA2B;IAC3B,8BAA+B;IAC/B,eAA+D;IAC/D,kBAAqB;IAqHvB;;;;;;;;;;;;OAYG;IACH,mBAwBC;IAxJC,wBAAyB;IAG3B;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,aASC;IAED;;;;OAIG;IACH,oBAEC;IAED;;;;OAIG;IACH,sBAEC;IAED;;OAEG;IACH,uBAFa,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAItD;IAED;;;;;aAcC;IAED;;;;;;OAMG;IACH,gBAHW,MAAM,GACJ,KAAK,CAKjB;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,KAAK,CAIjB;IAED;;;;;;OAMG;IACH,2BAFW,MAAM,QAUhB;IAyCD;;;;;;;;OAQG;IACH,+BAJW,MAAM,UACN,MAAM,GACJ,IAAI,CAoBhB;IAED;;;;;;;;;;;;OAYG;IACH;QALwC,MAAM,EAAnC,mBAAmB;QACF,UAAU;QACV,QAAQ;QACvB,mBAAmB,CA2B/B;CAoBF;;;;;cA1QY,OAAO,SAAS,CAAC;2BACjB,OAAO,uCAAuC,EAAE,mBAAmB"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
declare function _exports<K, V>(
|
|
1
|
+
declare function _exports<K, V>({ system, component, metric, metrics }: {
|
|
2
|
+
system?: string | undefined;
|
|
3
|
+
component: string;
|
|
4
|
+
metric: string;
|
|
5
|
+
metrics?: import(".") | undefined;
|
|
6
|
+
}): Map<K, V>;
|
|
2
7
|
export = _exports;
|
|
3
8
|
//# sourceMappingURL=tracked-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracked-map.d.ts","sourceRoot":"","sources":["../../../src/metrics/tracked-map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tracked-map.d.ts","sourceRoot":"","sources":["../../../src/metrics/tracked-map.js"],"names":[],"mappings":"AAkFiB;IANW,MAAM;IACP,SAAS,EAAzB,MAAM;IACU,MAAM,EAAtB,MAAM;IACgB,OAAO;cAcvC"}
|
|
@@ -21,7 +21,7 @@ declare class PeerRouting {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(libp2p: import('./'));
|
|
23
23
|
_peerId: import("peer-id");
|
|
24
|
-
_peerStore: import("./peer-store");
|
|
24
|
+
_peerStore: import("./peer-store/types").PeerStore;
|
|
25
25
|
/** @type {PeerRoutingModule[]} */
|
|
26
26
|
_routers: PeerRoutingModule[];
|
|
27
27
|
_refreshManagerOptions: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-routing.d.ts","sourceRoot":"","sources":["../../src/peer-routing.js"],"names":[],"mappings":";AA6BA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH;IACE;;;OAGG;IACH,oBAFW,OAAO,IAAI,CAAC,EAgBtB;IAbC,2BAA4B;IAC5B,
|
|
1
|
+
{"version":3,"file":"peer-routing.d.ts","sourceRoot":"","sources":["../../src/peer-routing.js"],"names":[],"mappings":";AA6BA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH;IACE;;;OAGG;IACH,oBAFW,OAAO,IAAI,CAAC,EAgBtB;IAbC,2BAA4B;IAC5B,mDAAkC;IAClC,kCAAkC;IAClC,UADW,iBAAiB,EAAE,CACmB;IAOjD;;;;8BAAwE;IAkB1E;;OAEG;IACH,uCAOC;IAvBD;;OAEG;IACH,cAQC;IAHC,gBAEC;IAeH;;OAEG;IACH,aAEC;IAED;;;;;;;OAOG;IACH,aALW,MAAM;;oBAGJ,QAAQ;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CA+B5D;IAED;;;;;;;;OAQG;IACH,qBANW,UAAU;;;oBAIR,cAAc;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,SAAS,EAAE,CAAA;KAAE,CAAC,CA2BlE;CACF;;;;yBA7IY,OAAO,0CAA0C,EAAE,WAAW;;;;;;;;;;;;;;;;;;;cAF9D,OAAO,SAAS,CAAC;iBACjB,OAAO,WAAW,EAAE,SAAS"}
|
|
@@ -1,121 +1,67 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = PeerStoreAddressBook;
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @implements {AddressBook}
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* @typedef {Object} Address
|
|
7
|
-
* @property {Multiaddr} multiaddr peer multiaddr.
|
|
8
|
-
* @property {boolean} isCertified obtained from a signed peer record.
|
|
9
|
-
*
|
|
10
|
-
* @typedef {Object} CertifiedRecord
|
|
11
|
-
* @property {Uint8Array} raw raw envelope.
|
|
12
|
-
* @property {number} seqNumber seq counter.
|
|
13
|
-
*
|
|
14
|
-
* @typedef {Object} Entry
|
|
15
|
-
* @property {Address[]} addresses peer Addresses.
|
|
16
|
-
* @property {CertifiedRecord} record certified peer record.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* @extends {Book}
|
|
20
|
-
*/
|
|
21
|
-
declare class AddressBook extends Book {
|
|
5
|
+
declare class PeerStoreAddressBook implements AddressBook {
|
|
22
6
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
26
|
-
* @param {PeerStore} peerStore
|
|
7
|
+
* @param {PeerStore["emit"]} emit
|
|
8
|
+
* @param {import('./types').Store} store
|
|
9
|
+
* @param {(peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>} addressFilter
|
|
27
10
|
*/
|
|
28
|
-
constructor(
|
|
11
|
+
constructor(emit: PeerStore["emit"], store: import('./types').Store, addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>);
|
|
12
|
+
_emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
|
|
13
|
+
_store: import("./types").Store;
|
|
14
|
+
_addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>;
|
|
29
15
|
/**
|
|
30
16
|
* ConsumePeerRecord adds addresses from a signed peer record contained in a record envelope.
|
|
31
17
|
* This will return a boolean that indicates if the record was successfully processed and added
|
|
32
18
|
* into the AddressBook.
|
|
33
19
|
*
|
|
34
20
|
* @param {Envelope} envelope
|
|
35
|
-
* @returns {boolean}
|
|
36
21
|
*/
|
|
37
|
-
consumePeerRecord(envelope: Envelope): boolean
|
|
22
|
+
consumePeerRecord(envelope: Envelope): Promise<boolean>;
|
|
38
23
|
/**
|
|
39
|
-
* Get the raw Envelope for a peer. Returns
|
|
40
|
-
* undefined if no Envelope is found.
|
|
41
|
-
*
|
|
42
24
|
* @param {PeerId} peerId
|
|
43
|
-
* @returns {Uint8Array|undefined}
|
|
44
25
|
*/
|
|
45
|
-
getRawEnvelope(peerId: PeerId): Uint8Array | undefined
|
|
26
|
+
getRawEnvelope(peerId: PeerId): Promise<Uint8Array | undefined>;
|
|
46
27
|
/**
|
|
47
28
|
* Get an Envelope containing a PeerRecord for the given peer.
|
|
48
29
|
* Returns undefined if no record exists.
|
|
49
30
|
*
|
|
50
31
|
* @param {PeerId} peerId
|
|
51
|
-
* @returns {Promise<Envelope|void>|undefined}
|
|
52
32
|
*/
|
|
53
|
-
getPeerRecord(peerId: PeerId): Promise<Envelope |
|
|
33
|
+
getPeerRecord(peerId: PeerId): Promise<Envelope | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* @param {PeerId} peerId
|
|
36
|
+
*/
|
|
37
|
+
get(peerId: PeerId): Promise<import("./types").Address[]>;
|
|
54
38
|
/**
|
|
55
|
-
* Add known addresses of a provided peer.
|
|
56
|
-
* If the peer is not known, it is set with the given addresses.
|
|
57
|
-
*
|
|
58
39
|
* @param {PeerId} peerId
|
|
59
40
|
* @param {Multiaddr[]} multiaddrs
|
|
60
|
-
* @returns {AddressBook}
|
|
61
41
|
*/
|
|
62
|
-
|
|
42
|
+
set(peerId: PeerId, multiaddrs: Multiaddr[]): Promise<void>;
|
|
63
43
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @private
|
|
44
|
+
* @param {PeerId} peerId
|
|
67
45
|
* @param {Multiaddr[]} multiaddrs
|
|
68
|
-
* @param {boolean} [isCertified]
|
|
69
|
-
* @returns {Address[]}
|
|
70
46
|
*/
|
|
71
|
-
|
|
47
|
+
add(peerId: PeerId, multiaddrs: Multiaddr[]): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @param {PeerId} peerId
|
|
50
|
+
*/
|
|
51
|
+
delete(peerId: PeerId): Promise<void>;
|
|
72
52
|
/**
|
|
73
|
-
* Get the known multiaddrs for a given peer. All returned multiaddrs
|
|
74
|
-
* will include the encapsulated `PeerId` of the peer.
|
|
75
|
-
* Returns `undefined` if there are no known multiaddrs for the given peer.
|
|
76
|
-
*
|
|
77
53
|
* @param {PeerId} peerId
|
|
78
54
|
* @param {(addresses: Address[]) => Address[]} [addressSorter]
|
|
79
|
-
* @returns {Multiaddr[]|undefined}
|
|
80
55
|
*/
|
|
81
|
-
getMultiaddrsForPeer(peerId: PeerId, addressSorter?: ((addresses: Address[]) => Address[]) | undefined): Multiaddr[]
|
|
56
|
+
getMultiaddrsForPeer(peerId: PeerId, addressSorter?: ((addresses: Address[]) => Address[]) | undefined): Promise<Multiaddr[]>;
|
|
82
57
|
}
|
|
83
|
-
declare namespace
|
|
84
|
-
export { PeerStore, Address,
|
|
58
|
+
declare namespace PeerStoreAddressBook {
|
|
59
|
+
export { PeerStore, Address, AddressBook };
|
|
85
60
|
}
|
|
86
|
-
|
|
61
|
+
type AddressBook = import('./types').AddressBook;
|
|
87
62
|
import Envelope = require("../record/envelope");
|
|
88
63
|
import PeerId = require("peer-id");
|
|
89
64
|
import { Multiaddr } from "multiaddr";
|
|
90
|
-
type PeerStore = import('./');
|
|
91
|
-
type Address =
|
|
92
|
-
/**
|
|
93
|
-
* peer multiaddr.
|
|
94
|
-
*/
|
|
95
|
-
multiaddr: Multiaddr;
|
|
96
|
-
/**
|
|
97
|
-
* obtained from a signed peer record.
|
|
98
|
-
*/
|
|
99
|
-
isCertified: boolean;
|
|
100
|
-
};
|
|
101
|
-
type CertifiedRecord = {
|
|
102
|
-
/**
|
|
103
|
-
* raw envelope.
|
|
104
|
-
*/
|
|
105
|
-
raw: Uint8Array;
|
|
106
|
-
/**
|
|
107
|
-
* seq counter.
|
|
108
|
-
*/
|
|
109
|
-
seqNumber: number;
|
|
110
|
-
};
|
|
111
|
-
type Entry = {
|
|
112
|
-
/**
|
|
113
|
-
* peer Addresses.
|
|
114
|
-
*/
|
|
115
|
-
addresses: Address[];
|
|
116
|
-
/**
|
|
117
|
-
* certified peer record.
|
|
118
|
-
*/
|
|
119
|
-
record: CertifiedRecord;
|
|
120
|
-
};
|
|
65
|
+
type PeerStore = import('./types').PeerStore;
|
|
66
|
+
type Address = import('./types').Address;
|
|
121
67
|
//# sourceMappingURL=address-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/address-book.js"],"names":[],"mappings":";AA2BA;;GAEG;AACH;IACE;;;;OAIG;IACH,kBAJW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,0BACd,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC,EAMpE;IAHC,2IAAiB;IACjB,gCAAmB;IACnB,yBALkB,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC,CAKhC;IAGrC;;;;;;OAMG;IACH,4BAFW,QAAQ,oBA+DlB;IAED;;OAEG;IACH,uBAFW,MAAM,mCAmBhB;IAED;;;;;OAKG;IACH,sBAFW,MAAM,iCAUhB;IAED;;OAEG;IACH,YAFW,MAAM,wCA0BhB;IAED;;;OAGG;IACH,YAHW,MAAM,cACN,SAAS,EAAE,iBA2DrB;IAED;;;OAGG;IACH,YAHW,MAAM,cACN,SAAS,EAAE,iBA0DrB;IAED;;OAEG;IACH,eAFW,MAAM,iBA4BhB;IAED;;;OAGG;IACH,6BAHW,MAAM,+BACM,OAAO,EAAE,KAAK,OAAO,EAAE,qCAe7C;CACF;;;;mBA/UY,OAAO,SAAS,EAAE,WAAW;;;;iBAF7B,OAAO,SAAS,EAAE,SAAS;eAC3B,OAAO,SAAS,EAAE,OAAO"}
|
|
@@ -1,124 +1,58 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = DefaultPeerStore;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @extends {EventEmitter}
|
|
3
|
+
* An implementation of PeerStore that stores data in a Datastore
|
|
7
4
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @fires PeerStore#change:protocols Emitted when a known peer supports a different set of protocols.
|
|
10
|
-
* @fires PeerStore#change:multiaddrs Emitted when a known peer has a different set of multiaddrs.
|
|
11
|
-
* @fires PeerStore#change:pubkey Emitted emitted when a peer's public key is known.
|
|
12
|
-
* @fires PeerStore#change:metadata Emitted when the known metadata of a peer change.
|
|
5
|
+
* @implements {PeerStore}
|
|
13
6
|
*/
|
|
14
|
-
declare class
|
|
15
|
-
/**
|
|
16
|
-
* Peer object
|
|
17
|
-
*
|
|
18
|
-
* @typedef {Object} Peer
|
|
19
|
-
* @property {PeerId} id peer's peer-id instance.
|
|
20
|
-
* @property {Address[]} addresses peer's addresses containing its multiaddrs and metadata.
|
|
21
|
-
* @property {string[]} protocols peer's supported protocols.
|
|
22
|
-
* @property {Map<string, Uint8Array>|undefined} metadata peer's metadata map.
|
|
23
|
-
*/
|
|
7
|
+
declare class DefaultPeerStore extends EventEmitter implements PeerStore {
|
|
24
8
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {PeerId}
|
|
29
|
-
* @class
|
|
9
|
+
* @param {object} properties
|
|
10
|
+
* @param {PeerId} properties.peerId
|
|
11
|
+
* @param {import('interface-datastore').Datastore} properties.datastore
|
|
12
|
+
* @param {(peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>} properties.addressFilter
|
|
30
13
|
*/
|
|
31
|
-
constructor({ peerId }: {
|
|
14
|
+
constructor({ peerId, datastore, addressFilter }: {
|
|
32
15
|
peerId: PeerId;
|
|
16
|
+
datastore: import('interface-datastore').Datastore;
|
|
17
|
+
addressFilter: (peerId: PeerId, multiaddr: Multiaddr) => Promise<boolean>;
|
|
33
18
|
});
|
|
34
|
-
_peerId:
|
|
35
|
-
|
|
36
|
-
* AddressBook containing a map of peerIdStr to Address.
|
|
37
|
-
*/
|
|
19
|
+
_peerId: import("peer-id");
|
|
20
|
+
_store: Store;
|
|
38
21
|
addressBook: AddressBook;
|
|
39
|
-
/**
|
|
40
|
-
* KeyBook containing a map of peerIdStr to their PeerId with public keys.
|
|
41
|
-
*/
|
|
42
22
|
keyBook: KeyBook;
|
|
43
|
-
/**
|
|
44
|
-
* MetadataBook containing a map of peerIdStr to their metadata Map.
|
|
45
|
-
*/
|
|
46
23
|
metadataBook: MetadataBook;
|
|
47
|
-
/**
|
|
48
|
-
* ProtoBook containing a map of peerIdStr to supported protocols.
|
|
49
|
-
*/
|
|
50
24
|
protoBook: ProtoBook;
|
|
25
|
+
getPeers(): AsyncGenerator<import("./types").Peer, void, unknown>;
|
|
51
26
|
/**
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
|
-
start(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Stop the PeerStore.
|
|
57
|
-
*/
|
|
58
|
-
stop(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get all the stored information of every peer known.
|
|
27
|
+
* Delete the information of the given peer in every book
|
|
61
28
|
*
|
|
62
|
-
* @
|
|
29
|
+
* @param {PeerId} peerId
|
|
63
30
|
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* peer's peer-id instance.
|
|
67
|
-
*/
|
|
68
|
-
id: PeerId;
|
|
69
|
-
/**
|
|
70
|
-
* peer's addresses containing its multiaddrs and metadata.
|
|
71
|
-
*/
|
|
72
|
-
addresses: Address[];
|
|
73
|
-
/**
|
|
74
|
-
* peer's supported protocols.
|
|
75
|
-
*/
|
|
76
|
-
protocols: string[];
|
|
77
|
-
/**
|
|
78
|
-
* peer's metadata map.
|
|
79
|
-
*/
|
|
80
|
-
metadata: Map<string, Uint8Array> | undefined;
|
|
81
|
-
}>;
|
|
31
|
+
delete(peerId: PeerId): Promise<void>;
|
|
82
32
|
/**
|
|
83
|
-
*
|
|
33
|
+
* Get the stored information of a given peer
|
|
84
34
|
*
|
|
85
35
|
* @param {PeerId} peerId
|
|
86
|
-
* @returns {boolean} true if found and removed
|
|
87
36
|
*/
|
|
88
|
-
|
|
37
|
+
get(peerId: PeerId): Promise<import("./types").Peer>;
|
|
89
38
|
/**
|
|
90
|
-
*
|
|
39
|
+
* Returns true if we have a record of the peer
|
|
91
40
|
*
|
|
92
41
|
* @param {PeerId} peerId
|
|
93
|
-
* @returns {Peer|undefined}
|
|
94
42
|
*/
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* peer's peer-id instance.
|
|
98
|
-
*/
|
|
99
|
-
id: PeerId;
|
|
100
|
-
/**
|
|
101
|
-
* peer's addresses containing its multiaddrs and metadata.
|
|
102
|
-
*/
|
|
103
|
-
addresses: Address[];
|
|
104
|
-
/**
|
|
105
|
-
* peer's supported protocols.
|
|
106
|
-
*/
|
|
107
|
-
protocols: string[];
|
|
108
|
-
/**
|
|
109
|
-
* peer's metadata map.
|
|
110
|
-
*/
|
|
111
|
-
metadata: Map<string, Uint8Array> | undefined;
|
|
112
|
-
} | undefined;
|
|
43
|
+
has(peerId: PeerId): Promise<boolean>;
|
|
113
44
|
}
|
|
114
|
-
declare namespace
|
|
115
|
-
export {
|
|
45
|
+
declare namespace DefaultPeerStore {
|
|
46
|
+
export { PeerStore, Peer, PeerId, Multiaddr };
|
|
116
47
|
}
|
|
48
|
+
type PeerStore = import('./types').PeerStore;
|
|
117
49
|
import { EventEmitter } from "events";
|
|
118
|
-
import
|
|
50
|
+
import Store = require("./store");
|
|
119
51
|
import AddressBook = require("./address-book");
|
|
120
52
|
import KeyBook = require("./key-book");
|
|
121
53
|
import MetadataBook = require("./metadata-book");
|
|
122
54
|
import ProtoBook = require("./proto-book");
|
|
123
|
-
type
|
|
55
|
+
type PeerId = import('peer-id');
|
|
56
|
+
type Multiaddr = import('multiaddr').Multiaddr;
|
|
57
|
+
type Peer = import('./types').Peer;
|
|
124
58
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/peer-store/index.js"],"names":[],"mappings":";AAqBA;;;;GAIG;AACH;IACE;;;;;OAKG;IACH;gBAJW,MAAM;mBACN,OAAO,qBAAqB,EAAE,SAAS;gCAC9B,MAAM,aAAa,SAAS,KAAK,QAAQ,OAAO,CAAC;OAYpE;IAPC,2BAAqB;IACrB,cAAkC;IAElC,yBAAoF;IACpF,iBAA6D;IAC7D,2BAAuE;IACvE,qBAAiE;IAGnE,kEAkBC;IAED;;;;OAIG;IACH,eAFW,MAAM,iBAahB;IAED;;;;OAIG;IACH,YAFW,MAAM,mCAahB;IAED;;;;OAIG;IACH,YAFW,MAAM,oBAahB;CACF;;;;iBA3GY,OAAO,SAAS,EAAE,SAAS;;;;;;;cAE3B,OAAO,SAAS,CAAC;iBACjB,OAAO,WAAW,EAAE,SAAS;YAF7B,OAAO,SAAS,EAAE,IAAI"}
|
|
@@ -1,24 +1,40 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = PeerStoreKeyBook;
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
4
|
-
* @typedef {import('libp2p-crypto').PublicKey} PublicKey
|
|
3
|
+
* @implements {KeyBook}
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
* @extends {Book}
|
|
8
|
-
*/
|
|
9
|
-
declare class KeyBook extends Book {
|
|
5
|
+
declare class PeerStoreKeyBook implements KeyBook {
|
|
10
6
|
/**
|
|
11
7
|
* The KeyBook is responsible for keeping the known public keys of a peer.
|
|
12
8
|
*
|
|
13
|
-
* @
|
|
14
|
-
* @param {
|
|
9
|
+
* @param {PeerStore["emit"]} emit
|
|
10
|
+
* @param {import('./types').Store} store
|
|
11
|
+
*/
|
|
12
|
+
constructor(emit: PeerStore["emit"], store: import('./types').Store);
|
|
13
|
+
_emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
|
|
14
|
+
_store: import("./types").Store;
|
|
15
|
+
/**
|
|
16
|
+
* Set the Peer public key
|
|
17
|
+
*
|
|
18
|
+
* @param {PeerId} peerId
|
|
19
|
+
* @param {PublicKey} publicKey
|
|
20
|
+
*/
|
|
21
|
+
set(peerId: PeerId, publicKey: PublicKey): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Get Public key of the given PeerId, if stored
|
|
24
|
+
*
|
|
25
|
+
* @param {PeerId} peerId
|
|
26
|
+
*/
|
|
27
|
+
get(peerId: PeerId): Promise<import("libp2p-interfaces/src/keys/types").PublicKey | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* @param {PeerId} peerId
|
|
15
30
|
*/
|
|
16
|
-
|
|
31
|
+
delete(peerId: PeerId): Promise<void>;
|
|
17
32
|
}
|
|
18
|
-
declare namespace
|
|
19
|
-
export { PeerStore, PublicKey };
|
|
33
|
+
declare namespace PeerStoreKeyBook {
|
|
34
|
+
export { PeerStore, KeyBook, PublicKey };
|
|
20
35
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type PublicKey = import('libp2p-
|
|
36
|
+
type KeyBook = import('./types').KeyBook;
|
|
37
|
+
import PeerId = require("peer-id");
|
|
38
|
+
type PublicKey = import('libp2p-interfaces/src/keys/types').PublicKey;
|
|
39
|
+
type PeerStore = import('./types').PeerStore;
|
|
24
40
|
//# sourceMappingURL=key-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/key-book.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"key-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/key-book.js"],"names":[],"mappings":";AAoBA;;GAEG;AACH;IACE;;;;;OAKG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;;;;OAKG;IACH,YAHW,MAAM,aACN,SAAS,iBA4CnB;IAED;;;;OAIG;IACH,YAFW,MAAM,6EAwBhB;IAED;;OAEG;IACH,eAFW,MAAM,iBAsBhB;CACF;;;;eAhIY,OAAO,SAAS,EAAE,OAAO;;iBACzB,OAAO,kCAAkC,EAAE,SAAS;iBAFpD,OAAO,SAAS,EAAE,SAAS"}
|
|
@@ -1,54 +1,58 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = PeerStoreMetadataBook;
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @implements {MetadataBook}
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* @extends {Book}
|
|
7
|
-
*
|
|
8
|
-
* @fires MetadataBook#change:metadata
|
|
9
|
-
*/
|
|
10
|
-
declare class MetadataBook extends Book {
|
|
5
|
+
declare class PeerStoreMetadataBook implements MetadataBook {
|
|
11
6
|
/**
|
|
12
7
|
* The MetadataBook is responsible for keeping the known supported
|
|
13
|
-
* protocols of a peer
|
|
8
|
+
* protocols of a peer
|
|
14
9
|
*
|
|
15
|
-
* @
|
|
16
|
-
* @param {
|
|
10
|
+
* @param {PeerStore["emit"]} emit
|
|
11
|
+
* @param {import('./types').Store} store
|
|
17
12
|
*/
|
|
18
|
-
constructor(
|
|
13
|
+
constructor(emit: PeerStore["emit"], store: import('./types').Store);
|
|
14
|
+
_emit: <U extends keyof import("./types").PeerStoreEvents>(event: U, ...args: Parameters<import("./types").PeerStoreEvents[U]>) => boolean;
|
|
15
|
+
_store: import("./types").Store;
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
17
|
+
* Get the known data of a provided peer
|
|
21
18
|
*
|
|
22
19
|
* @param {PeerId} peerId
|
|
23
|
-
* @param {string} key
|
|
24
|
-
* @param {Uint8Array} value
|
|
25
|
-
* @param {object} [opts]
|
|
26
|
-
* @param {boolean} [opts.emit]
|
|
27
20
|
*/
|
|
28
|
-
|
|
29
|
-
emit?: boolean | undefined;
|
|
30
|
-
} | undefined): void;
|
|
21
|
+
get(peerId: PeerId): Promise<Map<any, any>>;
|
|
31
22
|
/**
|
|
32
23
|
* Get specific metadata value, if it exists
|
|
33
24
|
*
|
|
34
25
|
* @param {PeerId} peerId
|
|
35
26
|
* @param {string} key
|
|
36
|
-
* @returns {Uint8Array | undefined}
|
|
37
27
|
*/
|
|
38
|
-
getValue(peerId: PeerId, key: string): Uint8Array | undefined
|
|
28
|
+
getValue(peerId: PeerId, key: string): Promise<Uint8Array | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* @param {PeerId} peerId
|
|
31
|
+
* @param {Map<string, Uint8Array>} metadata
|
|
32
|
+
*/
|
|
33
|
+
set(peerId: PeerId, metadata: Map<string, Uint8Array>): Promise<void>;
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
35
|
+
* Set metadata key and value of a provided peer
|
|
41
36
|
*
|
|
37
|
+
* @param {PeerId} peerId
|
|
38
|
+
* @param {string} key - metadata key
|
|
39
|
+
* @param {Uint8Array} value - metadata value
|
|
40
|
+
*/
|
|
41
|
+
setValue(peerId: PeerId, key: string, value: Uint8Array): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* @param {PeerId} peerId
|
|
44
|
+
*/
|
|
45
|
+
delete(peerId: PeerId): Promise<void>;
|
|
46
|
+
/**
|
|
42
47
|
* @param {PeerId} peerId
|
|
43
48
|
* @param {string} key
|
|
44
|
-
* @returns {boolean}
|
|
45
49
|
*/
|
|
46
|
-
deleteValue(peerId: PeerId, key: string):
|
|
50
|
+
deleteValue(peerId: PeerId, key: string): Promise<void>;
|
|
47
51
|
}
|
|
48
|
-
declare namespace
|
|
49
|
-
export { PeerStore };
|
|
52
|
+
declare namespace PeerStoreMetadataBook {
|
|
53
|
+
export { PeerStore, MetadataBook };
|
|
50
54
|
}
|
|
51
|
-
|
|
55
|
+
type MetadataBook = import('./types').MetadataBook;
|
|
52
56
|
import PeerId = require("peer-id");
|
|
53
|
-
type PeerStore = import('./');
|
|
57
|
+
type PeerStore = import('./types').PeerStore;
|
|
54
58
|
//# sourceMappingURL=metadata-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/metadata-book.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"metadata-book.d.ts","sourceRoot":"","sources":["../../../src/peer-store/metadata-book.js"],"names":[],"mappings":";AAmBA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,kBAHW,SAAS,CAAC,MAAM,CAAC,SACjB,OAAO,SAAS,EAAE,KAAK,EAKjC;IAFC,2IAAiB;IACjB,gCAAmB;IAGrB;;;;OAIG;IACH,YAFW,MAAM,0BA0BhB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,OACN,MAAM,mCAwBhB;IAED;;;OAGG;IACH,YAHW,MAAM,YACN,IAAI,MAAM,EAAE,UAAU,CAAC,iBA2BjC;IAED;;;;;;OAMG;IACH,iBAJW,MAAM,OACN,MAAM,SACN,UAAU,iBA0CpB;IAED;;OAEG;IACH,eAFW,MAAM,iBA8BhB;IAED;;;OAGG;IACH,oBAHW,MAAM,OACN,MAAM,iBAmChB;CACF;;;;oBAzOY,OAAO,SAAS,EAAE,YAAY;;iBAD9B,OAAO,SAAS,EAAE,SAAS"}
|