libp2p 1.9.4 → 2.0.0-7cd984569
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 +17 -18
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +4 -3
- package/dist/src/components.js.map +1 -1
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +2 -7
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +3 -3
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +7 -7
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/connection-pruner.js +1 -1
- package/dist/src/connection-manager/constants.browser.d.ts +0 -8
- package/dist/src/connection-manager/constants.browser.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.browser.js +0 -8
- package/dist/src/connection-manager/constants.browser.js.map +1 -1
- package/dist/src/connection-manager/constants.d.ts +0 -8
- package/dist/src/connection-manager/constants.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.d.ts +12 -22
- package/dist/src/connection-manager/constants.defaults.d.ts.map +1 -1
- package/dist/src/connection-manager/constants.defaults.js +12 -22
- package/dist/src/connection-manager/constants.defaults.js.map +1 -1
- package/dist/src/connection-manager/constants.js +0 -8
- package/dist/src/connection-manager/constants.js.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +29 -15
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +47 -50
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +23 -57
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/connection-manager/reconnect-queue.d.ts +35 -0
- package/dist/src/connection-manager/reconnect-queue.d.ts.map +1 -0
- package/dist/src/connection-manager/reconnect-queue.js +104 -0
- package/dist/src/connection-manager/reconnect-queue.js.map +1 -0
- package/dist/src/connection-monitor.d.ts +1 -0
- package/dist/src/connection-monitor.d.ts.map +1 -1
- package/dist/src/connection-monitor.js +15 -5
- package/dist/src/connection-monitor.js.map +1 -1
- package/dist/src/content-routing.js +6 -6
- package/dist/src/content-routing.js.map +1 -1
- package/dist/src/errors.d.ts +41 -61
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +84 -63
- package/dist/src/errors.js.map +1 -1
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +4 -5
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/index.d.ts +27 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -10
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +13 -31
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.js +8 -8
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/registrar.js +7 -7
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +15 -23
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +8 -8
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +51 -51
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +21 -21
- package/src/components.ts +4 -3
- package/src/config.ts +4 -10
- package/src/connection/index.ts +9 -9
- package/src/connection-manager/connection-pruner.ts +1 -1
- package/src/connection-manager/constants.browser.ts +0 -10
- package/src/connection-manager/constants.defaults.ts +14 -27
- package/src/connection-manager/constants.ts +0 -10
- package/src/connection-manager/dial-queue.ts +30 -15
- package/src/connection-manager/index.ts +80 -118
- package/src/connection-manager/reconnect-queue.ts +134 -0
- package/src/connection-monitor.ts +15 -6
- package/src/content-routing.ts +6 -6
- package/src/errors.ts +96 -61
- package/src/get-peer.ts +4 -5
- package/src/index.ts +42 -12
- package/src/libp2p.ts +22 -36
- package/src/peer-routing.ts +8 -8
- package/src/registrar.ts +7 -7
- package/src/transport-manager.ts +15 -23
- package/src/upgrader.ts +55 -56
- package/src/version.ts +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +0 -47
- package/dist/src/connection-manager/auto-dial.d.ts.map +0 -1
- package/dist/src/connection-manager/auto-dial.js +0 -223
- package/dist/src/connection-manager/auto-dial.js.map +0 -1
- package/dist/typedoc-urls.json +0 -14
- package/src/connection-manager/auto-dial.ts +0 -285
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGhT,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,U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,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,GAAG,CAAC,EAAE,GAAG,CAAA;CACV;AA8ED,wBAAgB,iBAAiB,CAAE,IAAI,GAAE,cAAmB,GAAG,UAAU,CA+BxE;AAED,wBAAgB,wBAAwB,CAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAgBtE"}
|
package/dist/src/components.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serviceCapabilities, serviceDependencies } from '@libp2p/interface';
|
|
2
2
|
import { isStartable } from '@libp2p/interface';
|
|
3
3
|
import { defaultLogger } from '@libp2p/logger';
|
|
4
|
+
import { MissingServiceError, UnmetServiceDependenciesError } from './errors.js';
|
|
4
5
|
class DefaultComponents {
|
|
5
6
|
components = {};
|
|
6
7
|
_started = false;
|
|
@@ -68,7 +69,7 @@ export function defaultComponents(init = {}) {
|
|
|
68
69
|
if (typeof prop === 'string' && !NON_SERVICE_PROPERTIES.includes(prop)) {
|
|
69
70
|
const service = components.components[prop];
|
|
70
71
|
if (service == null && !OPTIONAL_SERVICES.includes(prop)) {
|
|
71
|
-
throw new
|
|
72
|
+
throw new MissingServiceError(`${prop} not set`);
|
|
72
73
|
}
|
|
73
74
|
return service;
|
|
74
75
|
}
|
|
@@ -97,7 +98,7 @@ export function checkServiceDependencies(components) {
|
|
|
97
98
|
for (const service of Object.values(components.components)) {
|
|
98
99
|
for (const capability of getServiceDependencies(service)) {
|
|
99
100
|
if (serviceCapabilities[capability] !== true) {
|
|
100
|
-
throw new
|
|
101
|
+
throw new UnmetServiceDependenciesError(`Service "${getServiceName(service)}" required capability "${capability}" but it was not provided by any component, you may need to add additional configuration when creating your node.`);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAmQ,MAAM,mBAAmB,CAAA;AAChT,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAiDhF,MAAM,iBAAiB;IACd,UAAU,GAAwB,EAAE,CAAA;IACnC,QAAQ,GAAG,KAAK,CAAA;IAExB,YAAa,OAAuB,EAAE;QACpC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QAEpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC9B,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,aAAa,EAAE,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAE,UAAwF;QAC5H,MAAM,OAAO,CAAC,GAAG,CACf,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CAAA;QACxC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,KAAK,MAAM,UAAU,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;YACzD,IAAI,mBAAmB,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC7C,MAAM,IAAI,6BAA6B,CAAC,YAAY,cAAc,CAAC,OAAO,CAAC,0BAA0B,UAAU,mHAAmH,CAAC,CAAA;YACrO,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAE,OAAY;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,sBAAsB,CAAE,OAAY;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,cAAc,CAAE,OAAY;IACnC,OAAO,OAAO,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,EAAE,QAAQ,EAAE,IAAI,SAAS,CAAA;AAC1E,CAAC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Libp2pInit } from './index.js';
|
|
2
2
|
import type { ServiceMap } from '@libp2p/interface';
|
|
3
|
-
export declare function validateConfig<T extends ServiceMap = Record<string, unknown>>(opts: Libp2pInit<T>): Promise<Libp2pInit<T
|
|
3
|
+
export declare function validateConfig<T extends ServiceMap = Record<string, unknown>>(opts: Libp2pInit<T>): Promise<Libp2pInit<T>>;
|
|
4
4
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAqBnD,wBAAsB,cAAc,CAAE,CAAC,SAAS,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAQlI"}
|
package/dist/src/config.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { peerIdFromKeys } from '@libp2p/peer-id';
|
|
1
|
+
import { FaultTolerance, InvalidParametersError } from '@libp2p/interface';
|
|
3
2
|
import { defaultAddressSort } from '@libp2p/utils/address-sort';
|
|
4
3
|
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers';
|
|
5
4
|
import mergeOptions from 'merge-options';
|
|
6
|
-
import { codes, messages } from './errors.js';
|
|
7
5
|
const DefaultConfig = {
|
|
8
6
|
addresses: {
|
|
9
7
|
listen: [],
|
|
@@ -24,10 +22,7 @@ const DefaultConfig = {
|
|
|
24
22
|
export async function validateConfig(opts) {
|
|
25
23
|
const resultingOptions = mergeOptions(DefaultConfig, opts);
|
|
26
24
|
if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
|
|
27
|
-
throw new
|
|
28
|
-
}
|
|
29
|
-
if (resultingOptions.privateKey != null && !(await peerIdFromKeys(resultingOptions.privateKey.public.bytes, resultingOptions.privateKey.bytes)).equals(resultingOptions.peerId)) {
|
|
30
|
-
throw new CodeError('Private key doesn\'t match peer id', codes.ERR_INVALID_KEY);
|
|
25
|
+
throw new InvalidParametersError('Private network is enforced, but no protector was provided');
|
|
31
26
|
}
|
|
32
27
|
return resultingOptions;
|
|
33
28
|
}
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,YAAY,MAAM,eAAe,CAAA;AAKxC,MAAM,aAAa,GAAe;IAChC,SAAS,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,CAAC,UAAuB,EAAE,EAAE,CAAC,UAAU;KACxD;IACD,iBAAiB,EAAE;QACjB,SAAS,EAAE;YACT,OAAO,EAAE,eAAe;SACzB;QACD,aAAa,EAAE,kBAAkB;KAClC;IACD,gBAAgB,EAAE;QAChB,cAAc,EAAE,cAAc,CAAC,SAAS;KACzC;CACF,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAmD,IAAmB;IACxG,MAAM,gBAAgB,GAAkB,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IAEzE,IAAI,gBAAgB,CAAC,mBAAmB,KAAK,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,iBAAiB,IAAI,IAAI,EAAE,CAAC,CAAC,+BAA+B;QACxI,MAAM,IAAI,sBAAsB,CAAC,4DAA4D,CAAC,CAAA;IAChG,CAAC;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { connectionSymbol } from '@libp2p/interface';
|
|
2
|
-
import type { AbortOptions, Logger, ComponentLogger, Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions, PeerId } from '@libp2p/interface';
|
|
2
|
+
import type { AbortOptions, Logger, ComponentLogger, Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions, PeerId, ConnectionLimits } from '@libp2p/interface';
|
|
3
3
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
4
4
|
interface ConnectionInit {
|
|
5
5
|
remoteAddr: Multiaddr;
|
|
@@ -13,7 +13,7 @@ interface ConnectionInit {
|
|
|
13
13
|
timeline: ConnectionTimeline;
|
|
14
14
|
multiplexer?: string;
|
|
15
15
|
encryption?: string;
|
|
16
|
-
|
|
16
|
+
limits?: ConnectionLimits;
|
|
17
17
|
logger: ComponentLogger;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -38,7 +38,7 @@ export declare class ConnectionImpl implements Connection {
|
|
|
38
38
|
multiplexer?: string;
|
|
39
39
|
encryption?: string;
|
|
40
40
|
status: ConnectionStatus;
|
|
41
|
-
|
|
41
|
+
limits?: ConnectionLimits;
|
|
42
42
|
readonly log: Logger;
|
|
43
43
|
/**
|
|
44
44
|
* User provided tags
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0F,MAAM,mBAAmB,CAAA;AAC5I,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,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GG;IACI,IAAI,EAAE,MAAM,EAAE,CAAA;IAErB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsE;IAEjG;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAElE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAE5C;;;OAGG;gBACU,IAAI,EAAE,cAAc;IAyBjC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAe;IAE5C,QAAQ,CAAC,CAAC,gBAAgB,CAAC,QAAO;IAElC;;OAEG;IACH,IAAI,OAAO,IAAK,MAAM,EAAE,CAEvB;IAED;;OAEG;IACG,SAAS,CAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB3F;;OAEG;IACG,KAAK,CAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CvD,KAAK,CAAE,GAAG,EAAE,KAAK,GAAG,IAAI;CAczB;AAED,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,cAAc,GAAG,UAAU,CAElE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { connectionSymbol,
|
|
1
|
+
import { connectionSymbol, setMaxListeners, LimitedConnectionError, ConnectionClosedError, ConnectionClosingError } from '@libp2p/interface';
|
|
2
2
|
const CLOSE_TIMEOUT = 500;
|
|
3
3
|
/**
|
|
4
4
|
* An implementation of the js-libp2p connection.
|
|
@@ -22,7 +22,7 @@ export class ConnectionImpl {
|
|
|
22
22
|
multiplexer;
|
|
23
23
|
encryption;
|
|
24
24
|
status;
|
|
25
|
-
|
|
25
|
+
limits;
|
|
26
26
|
log;
|
|
27
27
|
/**
|
|
28
28
|
* User provided tags
|
|
@@ -56,7 +56,7 @@ export class ConnectionImpl {
|
|
|
56
56
|
this.timeline = init.timeline;
|
|
57
57
|
this.multiplexer = init.multiplexer;
|
|
58
58
|
this.encryption = init.encryption;
|
|
59
|
-
this.
|
|
59
|
+
this.limits = init.limits;
|
|
60
60
|
this.log = init.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`);
|
|
61
61
|
if (this.remoteAddr.getPeerId() == null) {
|
|
62
62
|
this.remoteAddr = this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`);
|
|
@@ -80,16 +80,16 @@ export class ConnectionImpl {
|
|
|
80
80
|
*/
|
|
81
81
|
async newStream(protocols, options) {
|
|
82
82
|
if (this.status === 'closing') {
|
|
83
|
-
throw new
|
|
83
|
+
throw new ConnectionClosingError('the connection is being closed');
|
|
84
84
|
}
|
|
85
85
|
if (this.status === 'closed') {
|
|
86
|
-
throw new
|
|
86
|
+
throw new ConnectionClosedError('the connection is closed');
|
|
87
87
|
}
|
|
88
88
|
if (!Array.isArray(protocols)) {
|
|
89
89
|
protocols = [protocols];
|
|
90
90
|
}
|
|
91
|
-
if (this.
|
|
92
|
-
throw new
|
|
91
|
+
if (this.limits != null && options?.runOnLimitedConnection !== true) {
|
|
92
|
+
throw new LimitedConnectionError('Cannot open protocol stream on limited connection');
|
|
93
93
|
}
|
|
94
94
|
const stream = await this._newStream(protocols, options);
|
|
95
95
|
stream.direction = 'outbound';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAI5I,MAAM,aAAa,GAAG,GAAG,CAAA;AAkBzB;;;GAGG;AACH,MAAM,OAAO,cAAc;IACzB;;OA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AC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6DAA6D,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;YACnG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IAED,KAAK,CAAE,GAAU;QACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wCAAwC,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAE9E,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;QACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;QAE3C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE1D,uBAAuB;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAEhB,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAA;IACxB,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAE,IAAoB;IACpD,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './constants.defaults.js';
|
|
2
|
-
/**
|
|
3
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections
|
|
4
|
-
*/
|
|
5
|
-
export declare const MIN_CONNECTIONS = 5;
|
|
6
2
|
/**
|
|
7
3
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections
|
|
8
4
|
*/
|
|
@@ -11,8 +7,4 @@ export declare const MAX_CONNECTIONS = 100;
|
|
|
11
7
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials
|
|
12
8
|
*/
|
|
13
9
|
export declare const MAX_PARALLEL_DIALS = 50;
|
|
14
|
-
/**
|
|
15
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialPeerRetryThreshold
|
|
16
|
-
*/
|
|
17
|
-
export declare const AUTO_DIAL_PEER_RETRY_THRESHOLD: number;
|
|
18
10
|
//# sourceMappingURL=constants.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.browser.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.browser.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"constants.browser.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.browser.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './constants.defaults.js';
|
|
2
|
-
/**
|
|
3
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections
|
|
4
|
-
*/
|
|
5
|
-
export const MIN_CONNECTIONS = 5;
|
|
6
2
|
/**
|
|
7
3
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections
|
|
8
4
|
*/
|
|
@@ -11,8 +7,4 @@ export const MAX_CONNECTIONS = 100;
|
|
|
11
7
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials
|
|
12
8
|
*/
|
|
13
9
|
export const MAX_PARALLEL_DIALS = 50;
|
|
14
|
-
/**
|
|
15
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialPeerRetryThreshold
|
|
16
|
-
*/
|
|
17
|
-
export const AUTO_DIAL_PEER_RETRY_THRESHOLD = 1000 * 60 * 7;
|
|
18
10
|
//# sourceMappingURL=constants.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.browser.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.browser.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.browser.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.browser.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './constants.defaults.js';
|
|
2
|
-
/**
|
|
3
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections
|
|
4
|
-
*/
|
|
5
|
-
export declare const MIN_CONNECTIONS = 50;
|
|
6
2
|
/**
|
|
7
3
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections
|
|
8
4
|
*/
|
|
@@ -11,8 +7,4 @@ export declare const MAX_CONNECTIONS = 300;
|
|
|
11
7
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials
|
|
12
8
|
*/
|
|
13
9
|
export declare const MAX_PARALLEL_DIALS = 100;
|
|
14
|
-
/**
|
|
15
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialPeerRetryThreshold
|
|
16
|
-
*/
|
|
17
|
-
export declare const AUTO_DIAL_PEER_RETRY_THRESHOLD: number;
|
|
18
10
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,eAAe,MAAM,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAA"}
|
|
@@ -10,26 +10,6 @@ export declare const INBOUND_UPGRADE_TIMEOUT = 2000;
|
|
|
10
10
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxPeerAddrsToDial
|
|
11
11
|
*/
|
|
12
12
|
export declare const MAX_PEER_ADDRS_TO_DIAL = 25;
|
|
13
|
-
/**
|
|
14
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialInterval
|
|
15
|
-
*/
|
|
16
|
-
export declare const AUTO_DIAL_INTERVAL = 5000;
|
|
17
|
-
/**
|
|
18
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialConcurrency
|
|
19
|
-
*/
|
|
20
|
-
export declare const AUTO_DIAL_CONCURRENCY = 25;
|
|
21
|
-
/**
|
|
22
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialPriority
|
|
23
|
-
*/
|
|
24
|
-
export declare const AUTO_DIAL_PRIORITY = 0;
|
|
25
|
-
/**
|
|
26
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialMaxQueueLength
|
|
27
|
-
*/
|
|
28
|
-
export declare const AUTO_DIAL_MAX_QUEUE_LENGTH = 100;
|
|
29
|
-
/**
|
|
30
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialDiscoveredPeersDebounce
|
|
31
|
-
*/
|
|
32
|
-
export declare const AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE = 10;
|
|
33
13
|
/**
|
|
34
14
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundConnectionThreshold
|
|
35
15
|
*/
|
|
@@ -38,15 +18,25 @@ export declare const INBOUND_CONNECTION_THRESHOLD = 5;
|
|
|
38
18
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxIncomingPendingConnections
|
|
39
19
|
*/
|
|
40
20
|
export declare const MAX_INCOMING_PENDING_CONNECTIONS = 10;
|
|
21
|
+
/**
|
|
22
|
+
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelReconnects
|
|
23
|
+
*/
|
|
24
|
+
export declare const MAX_PARALLEL_RECONNECTS = 5;
|
|
41
25
|
/**
|
|
42
26
|
* Store as part of the peer store metadata for a given peer, the value for this
|
|
43
|
-
* key is a timestamp of the last time a dial
|
|
44
|
-
*
|
|
27
|
+
* key is a timestamp of the last time a dial attempt failed with the timestamp
|
|
28
|
+
* stored as a string.
|
|
45
29
|
*
|
|
46
30
|
* Used to insure we do not endlessly try to auto dial peers we have recently
|
|
47
31
|
* failed to dial.
|
|
48
32
|
*/
|
|
49
33
|
export declare const LAST_DIAL_FAILURE_KEY = "last-dial-failure";
|
|
34
|
+
/**
|
|
35
|
+
* Store as part of the peer store metadata for a given peer, the value for this
|
|
36
|
+
* key is a timestamp of the last time a dial attempt succeeded with the
|
|
37
|
+
* timestamp stored as a string.
|
|
38
|
+
*/
|
|
39
|
+
export declare const LAST_DIAL_SUCCESS_KEY = "last-dial-success";
|
|
50
40
|
/**
|
|
51
41
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxDialQueueLength
|
|
52
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.defaults.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.defaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,OAAM,CAAA;AAE/B;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAAM,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.defaults.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/constants.defaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,OAAM,CAAA;AAE/B;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAAM,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC;;GAEG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,gCAAgC,KAAK,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAA;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,sBAAsB,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,sBAAsB,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAA"}
|
|
@@ -10,26 +10,6 @@ export const INBOUND_UPGRADE_TIMEOUT = 2e3;
|
|
|
10
10
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxPeerAddrsToDial
|
|
11
11
|
*/
|
|
12
12
|
export const MAX_PEER_ADDRS_TO_DIAL = 25;
|
|
13
|
-
/**
|
|
14
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialInterval
|
|
15
|
-
*/
|
|
16
|
-
export const AUTO_DIAL_INTERVAL = 5000;
|
|
17
|
-
/**
|
|
18
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialConcurrency
|
|
19
|
-
*/
|
|
20
|
-
export const AUTO_DIAL_CONCURRENCY = 25;
|
|
21
|
-
/**
|
|
22
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialPriority
|
|
23
|
-
*/
|
|
24
|
-
export const AUTO_DIAL_PRIORITY = 0;
|
|
25
|
-
/**
|
|
26
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#autoDialMaxQueueLength
|
|
27
|
-
*/
|
|
28
|
-
export const AUTO_DIAL_MAX_QUEUE_LENGTH = 100;
|
|
29
|
-
/**
|
|
30
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialDiscoveredPeersDebounce
|
|
31
|
-
*/
|
|
32
|
-
export const AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE = 10;
|
|
33
13
|
/**
|
|
34
14
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#inboundConnectionThreshold
|
|
35
15
|
*/
|
|
@@ -38,15 +18,25 @@ export const INBOUND_CONNECTION_THRESHOLD = 5;
|
|
|
38
18
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxIncomingPendingConnections
|
|
39
19
|
*/
|
|
40
20
|
export const MAX_INCOMING_PENDING_CONNECTIONS = 10;
|
|
21
|
+
/**
|
|
22
|
+
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelReconnects
|
|
23
|
+
*/
|
|
24
|
+
export const MAX_PARALLEL_RECONNECTS = 5;
|
|
41
25
|
/**
|
|
42
26
|
* Store as part of the peer store metadata for a given peer, the value for this
|
|
43
|
-
* key is a timestamp of the last time a dial
|
|
44
|
-
*
|
|
27
|
+
* key is a timestamp of the last time a dial attempt failed with the timestamp
|
|
28
|
+
* stored as a string.
|
|
45
29
|
*
|
|
46
30
|
* Used to insure we do not endlessly try to auto dial peers we have recently
|
|
47
31
|
* failed to dial.
|
|
48
32
|
*/
|
|
49
33
|
export const LAST_DIAL_FAILURE_KEY = 'last-dial-failure';
|
|
34
|
+
/**
|
|
35
|
+
* Store as part of the peer store metadata for a given peer, the value for this
|
|
36
|
+
* key is a timestamp of the last time a dial attempt succeeded with the
|
|
37
|
+
* timestamp stored as a string.
|
|
38
|
+
*/
|
|
39
|
+
export const LAST_DIAL_SUCCESS_KEY = 'last-dial-success';
|
|
50
40
|
/**
|
|
51
41
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxDialQueueLength
|
|
52
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.defaults.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.defaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.defaults.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.defaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,CAAA;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAA;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAA;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export * from './constants.defaults.js';
|
|
2
|
-
/**
|
|
3
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#minConnections
|
|
4
|
-
*/
|
|
5
|
-
export const MIN_CONNECTIONS = 50;
|
|
6
2
|
/**
|
|
7
3
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxConnections
|
|
8
4
|
*/
|
|
@@ -11,8 +7,4 @@ export const MAX_CONNECTIONS = 300;
|
|
|
11
7
|
* @see https://libp2p.github.io/js-libp2p/interfaces/index._internal_.ConnectionManagerConfig.html#maxParallelDials
|
|
12
8
|
*/
|
|
13
9
|
export const MAX_PARALLEL_DIALS = 100;
|
|
14
|
-
/**
|
|
15
|
-
* @see https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.unknown.ConnectionManagerInit.html#autoDialPeerRetryThreshold
|
|
16
|
-
*/
|
|
17
|
-
export const AUTO_DIAL_PEER_RETRY_THRESHOLD = 1000 * 60;
|
|
18
10
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/connection-manager/constants.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dial-queue.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/dial-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC1F,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAwB,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"dial-queue.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/dial-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC1F,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAwB,MAAM,yBAAyB,CAAA;AAkB7F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAU,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAW,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAC/M,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAA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Q;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,kBAAkB,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;gBAEf,UAAU,EAAE,mBAAmB,EAAE,IAAI,GAAE,UAAe;IA4BnE,KAAK,IAAK,IAAI;IAKd;;OAEG;IACH,IAAI,IAAK,IAAI;IAKb;;;;;;;;;;;OAWG;IACG,IAAI,CAAE,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,UAAU,CAAC;IA2K1H,OAAO,CAAC,yBAAyB;YAenB,mBAAmB;IAgK3B,UAAU,CAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;CAsBzG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-depth */
|
|
2
|
-
import {
|
|
2
|
+
import { TimeoutError, DialError, setMaxListeners } from '@libp2p/interface';
|
|
3
3
|
import { PeerMap } from '@libp2p/peer-collections';
|
|
4
4
|
import { defaultAddressSort } from '@libp2p/utils/address-sort';
|
|
5
5
|
import { PriorityQueue } from '@libp2p/utils/priority-queue';
|
|
@@ -9,9 +9,9 @@ import { Circuit } from '@multiformats/multiaddr-matcher';
|
|
|
9
9
|
import { anySignal } from 'any-signal';
|
|
10
10
|
import { CustomProgressEvent } from 'progress-events';
|
|
11
11
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
12
|
-
import {
|
|
12
|
+
import { DialDeniedError, NoValidAddressesError } from '../errors.js';
|
|
13
13
|
import { getPeerAddress } from '../get-peer.js';
|
|
14
|
-
import { DIAL_TIMEOUT, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL, LAST_DIAL_FAILURE_KEY, MAX_DIAL_QUEUE_LENGTH } from './constants.js';
|
|
14
|
+
import { DIAL_TIMEOUT, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL, LAST_DIAL_FAILURE_KEY, MAX_DIAL_QUEUE_LENGTH, LAST_DIAL_SUCCESS_KEY } from './constants.js';
|
|
15
15
|
import { resolveMultiaddrs } from './utils.js';
|
|
16
16
|
import { DEFAULT_DIAL_PRIORITY } from './index.js';
|
|
17
17
|
const defaultOptions = {
|
|
@@ -129,7 +129,7 @@ export class DialQueue {
|
|
|
129
129
|
return existingDial.join(options);
|
|
130
130
|
}
|
|
131
131
|
if (this.queue.size >= this.maxDialQueueLength) {
|
|
132
|
-
throw new
|
|
132
|
+
throw new DialError('Dial queue is full');
|
|
133
133
|
}
|
|
134
134
|
this.log('creating dial target for %p', peerId, multiaddrs.map(ma => ma.toString()));
|
|
135
135
|
options.onProgress?.(new CustomProgressEvent('dial-queue:add-to-dial-queue'));
|
|
@@ -161,7 +161,7 @@ export class DialQueue {
|
|
|
161
161
|
for (const address of addrsToDial) {
|
|
162
162
|
if (dialed === this.maxPeerAddrsToDial) {
|
|
163
163
|
this.log('dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others', dialed, peerId);
|
|
164
|
-
throw new
|
|
164
|
+
throw new DialError('Peer had more than maxPeerAddrsToDial');
|
|
165
165
|
}
|
|
166
166
|
dialed++;
|
|
167
167
|
try {
|
|
@@ -170,6 +170,20 @@ export class DialQueue {
|
|
|
170
170
|
signal
|
|
171
171
|
});
|
|
172
172
|
this.log('dial to %a succeeded', address.multiaddr);
|
|
173
|
+
// record the successful dial and the address
|
|
174
|
+
try {
|
|
175
|
+
await this.components.peerStore.merge(conn.remotePeer, {
|
|
176
|
+
multiaddrs: [
|
|
177
|
+
conn.remoteAddr
|
|
178
|
+
],
|
|
179
|
+
metadata: {
|
|
180
|
+
[LAST_DIAL_SUCCESS_KEY]: uint8ArrayFromString(Date.now().toString())
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
this.log.error('could not update last dial failure key for %p', peerId, err);
|
|
186
|
+
}
|
|
173
187
|
return conn;
|
|
174
188
|
}
|
|
175
189
|
catch (err) {
|
|
@@ -177,7 +191,7 @@ export class DialQueue {
|
|
|
177
191
|
if (peerId != null) {
|
|
178
192
|
// record the failed dial
|
|
179
193
|
try {
|
|
180
|
-
await this.components.peerStore.
|
|
194
|
+
await this.components.peerStore.merge(peerId, {
|
|
181
195
|
metadata: {
|
|
182
196
|
[LAST_DIAL_FAILURE_KEY]: uint8ArrayFromString(Date.now().toString())
|
|
183
197
|
}
|
|
@@ -189,7 +203,7 @@ export class DialQueue {
|
|
|
189
203
|
}
|
|
190
204
|
// the user/dial timeout/shutdown controller signal aborted
|
|
191
205
|
if (signal.aborted) {
|
|
192
|
-
throw new
|
|
206
|
+
throw new TimeoutError(err.message);
|
|
193
207
|
}
|
|
194
208
|
errors.push(err);
|
|
195
209
|
}
|
|
@@ -197,7 +211,7 @@ export class DialQueue {
|
|
|
197
211
|
if (errors.length === 1) {
|
|
198
212
|
throw errors[0];
|
|
199
213
|
}
|
|
200
|
-
throw new
|
|
214
|
+
throw new AggregateError(errors, 'All multiaddr dials failed');
|
|
201
215
|
}
|
|
202
216
|
finally {
|
|
203
217
|
// clean up abort signals/controllers
|
|
@@ -231,10 +245,10 @@ export class DialQueue {
|
|
|
231
245
|
// if a peer id or multiaddr(s) with a peer id, make sure it isn't our peer id and that we are allowed to dial it
|
|
232
246
|
if (peerId != null) {
|
|
233
247
|
if (this.components.peerId.equals(peerId)) {
|
|
234
|
-
throw new
|
|
248
|
+
throw new DialError('Tried to dial self');
|
|
235
249
|
}
|
|
236
250
|
if ((await this.components.connectionGater.denyDialPeer?.(peerId)) === true) {
|
|
237
|
-
throw new
|
|
251
|
+
throw new DialDeniedError('The dial request is blocked by gater.allowDialPeer');
|
|
238
252
|
}
|
|
239
253
|
// if just a peer id was passed, load available multiaddrs for this peer
|
|
240
254
|
// from the peer store
|
|
@@ -246,7 +260,7 @@ export class DialQueue {
|
|
|
246
260
|
this.log('loaded multiaddrs for %p', peerId, addrs.map(({ multiaddr }) => multiaddr.toString()));
|
|
247
261
|
}
|
|
248
262
|
catch (err) {
|
|
249
|
-
if (err.
|
|
263
|
+
if (err.name !== 'NotFoundError') {
|
|
250
264
|
throw err;
|
|
251
265
|
}
|
|
252
266
|
}
|
|
@@ -264,7 +278,7 @@ export class DialQueue {
|
|
|
264
278
|
})));
|
|
265
279
|
}
|
|
266
280
|
catch (err) {
|
|
267
|
-
if (err.
|
|
281
|
+
if (err.name !== 'NoPeerRoutersError') {
|
|
268
282
|
this.log.error('looking up multiaddrs for %p in the peer routing failed', peerId, err);
|
|
269
283
|
}
|
|
270
284
|
}
|
|
@@ -334,7 +348,7 @@ export class DialQueue {
|
|
|
334
348
|
const dedupedMultiaddrs = [...dedupedAddrs.values()];
|
|
335
349
|
// make sure we actually have some addresses to dial
|
|
336
350
|
if (dedupedMultiaddrs.length === 0) {
|
|
337
|
-
throw new
|
|
351
|
+
throw new NoValidAddressesError('The dial request has no valid addresses');
|
|
338
352
|
}
|
|
339
353
|
const gatedAdrs = [];
|
|
340
354
|
for (const addr of dedupedMultiaddrs) {
|
|
@@ -346,7 +360,7 @@ export class DialQueue {
|
|
|
346
360
|
const sortedGatedAddrs = gatedAdrs.sort(this.addressSorter);
|
|
347
361
|
// make sure we actually have some addresses to dial
|
|
348
362
|
if (sortedGatedAddrs.length === 0) {
|
|
349
|
-
throw new
|
|
363
|
+
throw new DialDeniedError('The connection gater denied all addresses in the dial request');
|
|
350
364
|
}
|
|
351
365
|
this.log.trace('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()));
|
|
352
366
|
this.log.trace('addresses for %p after filtering', peerId ?? 'unknown peer', sortedGatedAddrs.map(({ multiaddr }) => multiaddr.toString()));
|
|
@@ -358,7 +372,7 @@ export class DialQueue {
|
|
|
358
372
|
}
|
|
359
373
|
try {
|
|
360
374
|
const addresses = await this.calculateMultiaddrs(undefined, new Set(multiaddr.map(ma => ma.toString())), options);
|
|
361
|
-
if (options.
|
|
375
|
+
if (options.runOnLimitedConnection === false) {
|
|
362
376
|
// return true if any resolved multiaddrs are not relay addresses
|
|
363
377
|
return addresses.find(addr => {
|
|
364
378
|
return !Circuit.matches(addr.multiaddr);
|