libp2p 1.9.1 → 1.9.2
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 +6 -6
- package/dist/src/connection-monitor.d.ts +7 -0
- package/dist/src/connection-monitor.d.ts.map +1 -1
- package/dist/src/connection-monitor.js +6 -1
- package/dist/src/connection-monitor.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/connection-monitor.ts +13 -1
- package/src/version.ts +1 -1
|
@@ -29,6 +29,12 @@ export interface ConnectionMonitorInit {
|
|
|
29
29
|
* @default true
|
|
30
30
|
*/
|
|
31
31
|
abortConnectionOnPingFailure?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Override the ping protocol prefix
|
|
34
|
+
*
|
|
35
|
+
* @default 'ipfs'
|
|
36
|
+
*/
|
|
37
|
+
protocolPrefix?: string;
|
|
32
38
|
}
|
|
33
39
|
export interface ConnectionMonitorComponents {
|
|
34
40
|
logger: ComponentLogger;
|
|
@@ -36,6 +42,7 @@ export interface ConnectionMonitorComponents {
|
|
|
36
42
|
metrics?: Metrics;
|
|
37
43
|
}
|
|
38
44
|
export declare class ConnectionMonitor implements Startable {
|
|
45
|
+
private readonly protocol;
|
|
39
46
|
private readonly components;
|
|
40
47
|
private readonly log;
|
|
41
48
|
private heartbeatInterval?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-monitor.d.ts","sourceRoot":"","sources":["../../src/connection-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAGvD,OAAO,KAAK,EAAE,eAAe,EAAU,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;
|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AC,WAAW,CAAC,gCAA+B;IAE5D,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAED,KAAK,IAAK,IAAI;IAoDd,IAAI,IAAK,IAAI;CAOd"}
|
|
@@ -2,7 +2,11 @@ import { serviceCapabilities } from '@libp2p/interface';
|
|
|
2
2
|
import { AdaptiveTimeout } from '@libp2p/utils/adaptive-timeout';
|
|
3
3
|
import { byteStream } from 'it-byte-stream';
|
|
4
4
|
const DEFAULT_PING_INTERVAL_MS = 10000;
|
|
5
|
+
const PROTOCOL_VERSION = '1.0.0';
|
|
6
|
+
const PROTOCOL_NAME = 'ping';
|
|
7
|
+
const PROTOCOL_PREFIX = 'ipfs';
|
|
5
8
|
export class ConnectionMonitor {
|
|
9
|
+
protocol;
|
|
6
10
|
components;
|
|
7
11
|
log;
|
|
8
12
|
heartbeatInterval;
|
|
@@ -11,6 +15,7 @@ export class ConnectionMonitor {
|
|
|
11
15
|
timeout;
|
|
12
16
|
constructor(components, init = {}) {
|
|
13
17
|
this.components = components;
|
|
18
|
+
this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`;
|
|
14
19
|
this.log = components.logger.forComponent('libp2p:connection-monitor');
|
|
15
20
|
this.pingIntervalMs = init.pingInterval ?? DEFAULT_PING_INTERVAL_MS;
|
|
16
21
|
this.timeout = new AdaptiveTimeout({
|
|
@@ -33,7 +38,7 @@ export class ConnectionMonitor {
|
|
|
33
38
|
const signal = this.timeout.getTimeoutSignal({
|
|
34
39
|
signal: this.abortController?.signal
|
|
35
40
|
});
|
|
36
|
-
const stream = await conn.newStream(
|
|
41
|
+
const stream = await conn.newStream(this.protocol, {
|
|
37
42
|
signal,
|
|
38
43
|
runOnTransientConnection: true
|
|
39
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-monitor.js","sourceRoot":"","sources":["../../src/connection-monitor.ts"],"names":[],"mapp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,MAAM,EAAE,CAAC,KAAK,CAAC;4BACtB,MAAM;yBACP,CAAC,CAAA;oBACJ,CAAC;oBAAC,OAAO,GAAQ,EAAE,CAAC;wBAClB,IAAI,GAAG,CAAC,IAAI,KAAK,0BAA0B,EAAE,CAAC;4BAC5C,MAAM,GAAG,CAAA;wBACX,CAAC;wBAED,iEAAiE;wBACjE,kEAAkE;wBAClE,gEAAgE;wBAChE,8CAA8C;wBAC9C,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;oBACrC,CAAC;gBACH,CAAC,CAAC;qBACC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6CAA6C,EAAE,GAAG,CAAC,CAAA;oBAClE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBACjB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACJ,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACzB,CAAC;IAED,IAAI;QACF,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,CAAA;QAE7B,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;YACnC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme",
|
|
@@ -6,6 +6,9 @@ import type { ConnectionManager } from '@libp2p/interface-internal'
|
|
|
6
6
|
import type { AdaptiveTimeoutInit } from '@libp2p/utils/adaptive-timeout'
|
|
7
7
|
|
|
8
8
|
const DEFAULT_PING_INTERVAL_MS = 10000
|
|
9
|
+
const PROTOCOL_VERSION = '1.0.0'
|
|
10
|
+
const PROTOCOL_NAME = 'ping'
|
|
11
|
+
const PROTOCOL_PREFIX = 'ipfs'
|
|
9
12
|
|
|
10
13
|
export interface ConnectionMonitorInit {
|
|
11
14
|
/**
|
|
@@ -37,6 +40,13 @@ export interface ConnectionMonitorInit {
|
|
|
37
40
|
* @default true
|
|
38
41
|
*/
|
|
39
42
|
abortConnectionOnPingFailure?: boolean
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Override the ping protocol prefix
|
|
46
|
+
*
|
|
47
|
+
* @default 'ipfs'
|
|
48
|
+
*/
|
|
49
|
+
protocolPrefix?: string
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
export interface ConnectionMonitorComponents {
|
|
@@ -46,6 +56,7 @@ export interface ConnectionMonitorComponents {
|
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
export class ConnectionMonitor implements Startable {
|
|
59
|
+
private readonly protocol: string
|
|
49
60
|
private readonly components: ConnectionMonitorComponents
|
|
50
61
|
private readonly log: Logger
|
|
51
62
|
private heartbeatInterval?: ReturnType<typeof setInterval>
|
|
@@ -55,6 +66,7 @@ export class ConnectionMonitor implements Startable {
|
|
|
55
66
|
|
|
56
67
|
constructor (components: ConnectionMonitorComponents, init: ConnectionMonitorInit = {}) {
|
|
57
68
|
this.components = components
|
|
69
|
+
this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
|
|
58
70
|
|
|
59
71
|
this.log = components.logger.forComponent('libp2p:connection-monitor')
|
|
60
72
|
this.pingIntervalMs = init.pingInterval ?? DEFAULT_PING_INTERVAL_MS
|
|
@@ -83,7 +95,7 @@ export class ConnectionMonitor implements Startable {
|
|
|
83
95
|
const signal = this.timeout.getTimeoutSignal({
|
|
84
96
|
signal: this.abortController?.signal
|
|
85
97
|
})
|
|
86
|
-
const stream = await conn.newStream(
|
|
98
|
+
const stream = await conn.newStream(this.protocol, {
|
|
87
99
|
signal,
|
|
88
100
|
runOnTransientConnection: true
|
|
89
101
|
})
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '1.9.
|
|
1
|
+
export const version = '1.9.2'
|
|
2
2
|
export const name = 'libp2p'
|