@libp2p/ping 2.0.37 → 3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAoC7C,MAAM,UAAU,IAAI,CAAE,OAAiB,EAAE;IACvC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACxD,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AA0B7C,MAAM,UAAU,IAAI,CAAE,OAAiB,EAAE;IACvC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACxD,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { serviceCapabilities } from '@libp2p/interface';
2
2
  import type { PingComponents, PingInit, Ping as PingInterface } from './index.js';
3
- import type { AbortOptions, PeerId, Startable, IncomingStreamData } from '@libp2p/interface';
3
+ import type { AbortOptions, Stream, PeerId, Startable, Connection } from '@libp2p/interface';
4
4
  import type { Multiaddr } from '@multiformats/multiaddr';
5
5
  export declare class Ping implements Startable, PingInterface {
6
6
  readonly protocol: string;
@@ -19,7 +19,7 @@ export declare class Ping implements Startable, PingInterface {
19
19
  /**
20
20
  * A handler to register with Libp2p to process ping messages
21
21
  */
22
- handleMessage(data: IncomingStreamData): void;
22
+ handlePing(stream: Stream, connection: Connection): Promise<void>;
23
23
  /**
24
24
  * Ping a given peer and wait for its response, getting the operation latency.
25
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAKpF,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AACjF,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,qBAAa,IAAK,YAAW,SAAS,EAAE,aAAa;IACnD,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;gBAEnC,UAAU,EAAE,cAAc,EAAE,IAAI,GAAE,QAAa;IAY5D,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAiB;IAE9C,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAEK,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IASvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAK5B,SAAS,IAAK,OAAO;IAIrB;;OAEG;IACH,aAAa,CAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAwD9C;;OAEG;IACG,IAAI,CAAE,IAAI,EAAE,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,IAAI,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;CAqDjG"}
package/dist/src/ping.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { randomBytes } from '@libp2p/crypto';
2
- import { ProtocolError, TimeoutError, serviceCapabilities } from '@libp2p/interface';
3
- import { byteStream } from 'it-byte-stream';
4
- import { setMaxListeners } from 'main-event';
2
+ import { ProtocolError, serviceCapabilities, setMaxListeners, TimeoutError } from '@libp2p/interface';
3
+ import { pEvent } from 'p-event';
4
+ import { raceSignal } from 'race-signal';
5
+ import { Uint8ArrayList } from 'uint8arraylist';
5
6
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
6
7
  import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js';
7
8
  export class Ping {
@@ -20,14 +21,14 @@ export class Ping {
20
21
  this.maxInboundStreams = init.maxInboundStreams ?? MAX_INBOUND_STREAMS;
21
22
  this.maxOutboundStreams = init.maxOutboundStreams ?? MAX_OUTBOUND_STREAMS;
22
23
  this.runOnLimitedConnection = init.runOnLimitedConnection ?? true;
23
- this.handleMessage = this.handleMessage.bind(this);
24
+ this.handlePing = this.handlePing.bind(this);
24
25
  }
25
26
  [Symbol.toStringTag] = '@libp2p/ping';
26
27
  [serviceCapabilities] = [
27
28
  '@libp2p/ping'
28
29
  ];
29
30
  async start() {
30
- await this.components.registrar.handle(this.protocol, this.handleMessage, {
31
+ await this.components.registrar.handle(this.protocol, this.handlePing, {
31
32
  maxInboundStreams: this.maxInboundStreams,
32
33
  maxOutboundStreams: this.maxOutboundStreams,
33
34
  runOnLimitedConnection: this.runOnLimitedConnection
@@ -44,98 +45,84 @@ export class Ping {
44
45
  /**
45
46
  * A handler to register with Libp2p to process ping messages
46
47
  */
47
- handleMessage(data) {
48
- const log = data.connection.log.newScope('ping');
49
- log.trace('ping from %p', data.connection.remotePeer);
50
- const { stream } = data;
48
+ async handlePing(stream, connection) {
49
+ const log = stream.log.newScope('ping');
50
+ log.trace('ping from %p', connection.remotePeer);
51
+ const signal = AbortSignal.timeout(this.timeout);
52
+ setMaxListeners(Infinity, signal);
53
+ signal.addEventListener('abort', () => {
54
+ stream.abort(new TimeoutError('Ping timed out'));
55
+ });
51
56
  const start = Date.now();
52
- const bytes = byteStream(stream);
53
- let pinged = false;
54
- Promise.resolve().then(async () => {
55
- while (true) {
56
- const signal = AbortSignal.timeout(this.timeout);
57
- setMaxListeners(Infinity, signal);
58
- signal.addEventListener('abort', () => {
59
- stream?.abort(new TimeoutError('ping timeout'));
60
- });
61
- const buf = await bytes.read({
62
- bytes: PING_LENGTH,
63
- signal
64
- });
65
- await bytes.write(buf, {
57
+ for await (const buf of stream) {
58
+ if (stream.status !== 'open') {
59
+ log('stream status changed to %s', stream.status);
60
+ break;
61
+ }
62
+ if (!stream.send(buf)) {
63
+ log('waiting for stream to drain');
64
+ await pEvent(stream, 'drain', {
65
+ rejectionEvents: [
66
+ 'close'
67
+ ],
66
68
  signal
67
69
  });
68
- pinged = true;
69
- }
70
- })
71
- .catch(err => {
72
- // ignore the error if we've processed at least one ping, the remote
73
- // closed the stream and we handled or are handling the close cleanly
74
- if (pinged && err.name === 'UnexpectedEOFError' && stream.readStatus !== 'ready') {
75
- return;
70
+ log('stream drained');
76
71
  }
77
- log.error('ping from %p failed with error - %e', data.connection.remotePeer, err);
78
- stream?.abort(err);
79
- })
80
- .finally(() => {
81
- const ms = Date.now() - start;
82
- log('ping from %p complete in %dms', data.connection.remotePeer, ms);
83
- const signal = AbortSignal.timeout(this.timeout);
84
- setMaxListeners(Infinity, signal);
85
- stream.close({
86
- signal
87
- })
88
- .catch(err => {
89
- log.error('error closing ping stream from %p - %e', data.connection.remotePeer, err);
90
- stream?.abort(err);
91
- });
72
+ }
73
+ log('ping from %p complete in %dms', connection.remotePeer, Date.now() - start);
74
+ await stream.close({
75
+ signal
92
76
  });
93
77
  }
94
78
  /**
95
79
  * Ping a given peer and wait for its response, getting the operation latency.
96
80
  */
97
81
  async ping(peer, options = {}) {
98
- const start = Date.now();
99
82
  const data = randomBytes(PING_LENGTH);
100
- const connection = await this.components.connectionManager.openConnection(peer, options);
101
- const log = connection.log.newScope('ping');
102
- let stream;
103
- if (options.signal == null) {
104
- const signal = AbortSignal.timeout(this.timeout);
105
- options = {
106
- ...options,
107
- signal
108
- };
109
- }
83
+ const stream = await this.components.connectionManager.openStream(peer, this.protocol, {
84
+ runOnLimitedConnection: this.runOnLimitedConnection,
85
+ ...options
86
+ });
87
+ const log = stream.log.newScope('ping');
110
88
  try {
111
- stream = await connection.newStream(this.protocol, {
112
- ...options,
113
- runOnLimitedConnection: this.runOnLimitedConnection
114
- });
115
- const bytes = byteStream(stream);
116
- const [, result] = await Promise.all([
117
- bytes.write(data, options),
118
- bytes.read({
119
- ...options,
120
- bytes: PING_LENGTH
121
- })
122
- ]);
123
- const ms = Date.now() - start;
124
- if (!uint8ArrayEquals(data, result.subarray())) {
125
- throw new ProtocolError(`Received wrong ping ack after ${ms}ms`);
126
- }
127
- log('ping %p complete in %dms', connection.remotePeer, ms);
128
- return ms;
89
+ const start = Date.now();
90
+ const finished = Promise.withResolvers();
91
+ const received = new Uint8ArrayList();
92
+ const onPong = (evt) => {
93
+ received.append(evt.data);
94
+ if (received.byteLength === PING_LENGTH) {
95
+ stream.removeEventListener('message', onPong);
96
+ const rtt = Date.now() - start;
97
+ Promise.all([
98
+ stream.closeRead(options)
99
+ ])
100
+ .then(() => {
101
+ if (!uint8ArrayEquals(data, received.subarray())) {
102
+ throw new ProtocolError(`Received wrong ping ack after ${rtt}ms`);
103
+ }
104
+ else {
105
+ finished.resolve(rtt);
106
+ }
107
+ })
108
+ .catch(err => {
109
+ stream.abort(err);
110
+ finished.reject(err);
111
+ });
112
+ }
113
+ };
114
+ stream.addEventListener('message', onPong);
115
+ stream.send(data);
116
+ await stream.close(options);
117
+ return await raceSignal(finished.promise, options.signal);
129
118
  }
130
119
  catch (err) {
131
- log.error('error while pinging %p', connection.remotePeer, err);
120
+ log.error('error while pinging %o - %e', peer, err);
132
121
  stream?.abort(err);
133
122
  throw err;
134
123
  }
135
124
  finally {
136
- if (stream != null) {
137
- await stream.close(options);
138
- }
125
+ stream?.close();
139
126
  }
140
127
  }
141
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ping.js","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAKlJ,MAAM,OAAO,IAAI;IACC,QAAQ,CAAQ;IACf,UAAU,CAAgB;IACnC,OAAO,CAAS;IACP,OAAO,CAAQ;IACf,iBAAiB,CAAQ;IACzB,kBAAkB,CAAQ;IAC1B,sBAAsB,CAAS;IAEhD,YAAa,UAA0B,EAAE,OAAiB,EAAE;QAC1D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,cAAc,IAAI,eAAe,IAAI,aAAa,IAAI,gBAAgB,EAAE,CAAA;QACjG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,OAA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C;YACT,MAAM,EAAE,KAAK,EAAE,CAAA;QACjB,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/ping",
3
- "version": "2.0.37",
3
+ "version": "3.0.0-049bfa0fa",
4
4
  "description": "Implementation of Ping Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-ping#readme",
@@ -43,20 +43,21 @@
43
43
  "doc-check": "aegir doc-check"
44
44
  },
45
45
  "dependencies": {
46
- "@libp2p/crypto": "^5.1.8",
47
- "@libp2p/interface": "^2.11.0",
48
- "@libp2p/interface-internal": "^2.3.19",
49
- "@multiformats/multiaddr": "^12.4.4",
50
- "it-byte-stream": "^2.0.2",
51
- "main-event": "^1.0.1",
46
+ "@libp2p/crypto": "5.1.9-049bfa0fa",
47
+ "@libp2p/interface": "3.0.0-049bfa0fa",
48
+ "@libp2p/interface-internal": "3.0.0-049bfa0fa",
49
+ "@multiformats/multiaddr": "^13.0.1",
50
+ "p-event": "^6.0.1",
51
+ "race-signal": "^2.0.0",
52
+ "uint8arraylist": "^2.4.8",
52
53
  "uint8arrays": "^5.1.0"
53
54
  },
54
55
  "devDependencies": {
55
- "@libp2p/logger": "^5.2.0",
56
- "@libp2p/peer-id": "^5.1.9",
57
- "aegir": "^47.0.14",
58
- "it-pair": "^2.0.6",
59
- "p-defer": "^4.0.1",
56
+ "@libp2p/peer-id": "6.0.0-049bfa0fa",
57
+ "@libp2p/utils": "7.0.0-049bfa0fa",
58
+ "aegir": "^47.0.22",
59
+ "delay": "^6.0.0",
60
+ "sinon": "^21.0.0",
60
61
  "sinon-ts": "^2.0.0"
61
62
  },
62
63
  "sideEffects": false
package/src/index.ts CHANGED
@@ -31,11 +31,6 @@ export interface Ping {
31
31
  ping(peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<number>
32
32
  }
33
33
 
34
- /**
35
- * @deprecated Use the `Ping` export instead
36
- */
37
- export type PingService = Ping
38
-
39
34
  export interface PingInit {
40
35
  protocolPrefix?: string
41
36
  maxInboundStreams?: number
@@ -48,11 +43,6 @@ export interface PingInit {
48
43
  timeout?: number
49
44
  }
50
45
 
51
- /**
52
- * @deprecated Use the `PingInit` export instead
53
- */
54
- export type PingServiceInit = PingInit
55
-
56
46
  export interface PingComponents {
57
47
  registrar: Registrar
58
48
  connectionManager: ConnectionManager
package/src/ping.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { randomBytes } from '@libp2p/crypto'
2
- import { ProtocolError, TimeoutError, serviceCapabilities } from '@libp2p/interface'
3
- import { byteStream } from 'it-byte-stream'
4
- import { setMaxListeners } from 'main-event'
2
+ import { ProtocolError, serviceCapabilities, setMaxListeners, TimeoutError } from '@libp2p/interface'
3
+ import { pEvent } from 'p-event'
4
+ import { raceSignal } from 'race-signal'
5
+ import { Uint8ArrayList } from 'uint8arraylist'
5
6
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
6
7
  import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js'
7
8
  import type { PingComponents, PingInit, Ping as PingInterface } from './index.js'
8
- import type { AbortOptions, Stream, PeerId, Startable, IncomingStreamData } from '@libp2p/interface'
9
+ import type { AbortOptions, Stream, PeerId, Startable, Connection, StreamMessageEvent } from '@libp2p/interface'
9
10
  import type { Multiaddr } from '@multiformats/multiaddr'
10
11
 
11
12
  export class Ping implements Startable, PingInterface {
@@ -26,7 +27,7 @@ export class Ping implements Startable, PingInterface {
26
27
  this.maxOutboundStreams = init.maxOutboundStreams ?? MAX_OUTBOUND_STREAMS
27
28
  this.runOnLimitedConnection = init.runOnLimitedConnection ?? true
28
29
 
29
- this.handleMessage = this.handleMessage.bind(this)
30
+ this.handlePing = this.handlePing.bind(this)
30
31
  }
31
32
 
32
33
  readonly [Symbol.toStringTag] = '@libp2p/ping'
@@ -36,7 +37,7 @@ export class Ping implements Startable, PingInterface {
36
37
  ]
37
38
 
38
39
  async start (): Promise<void> {
39
- await this.components.registrar.handle(this.protocol, this.handleMessage, {
40
+ await this.components.registrar.handle(this.protocol, this.handlePing, {
40
41
  maxInboundStreams: this.maxInboundStreams,
41
42
  maxOutboundStreams: this.maxOutboundStreams,
42
43
  runOnLimitedConnection: this.runOnLimitedConnection
@@ -56,116 +57,95 @@ export class Ping implements Startable, PingInterface {
56
57
  /**
57
58
  * A handler to register with Libp2p to process ping messages
58
59
  */
59
- handleMessage (data: IncomingStreamData): void {
60
- const log = data.connection.log.newScope('ping')
61
-
62
- log.trace('ping from %p', data.connection.remotePeer)
63
-
64
- const { stream } = data
60
+ async handlePing (stream: Stream, connection: Connection): Promise<void> {
61
+ const log = stream.log.newScope('ping')
62
+ log.trace('ping from %p', connection.remotePeer)
63
+ const signal = AbortSignal.timeout(this.timeout)
64
+ setMaxListeners(Infinity, signal)
65
+ signal.addEventListener('abort', () => {
66
+ stream.abort(new TimeoutError('Ping timed out'))
67
+ })
65
68
  const start = Date.now()
66
- const bytes = byteStream(stream)
67
- let pinged = false
68
-
69
- Promise.resolve().then(async () => {
70
- while (true) {
71
- const signal = AbortSignal.timeout(this.timeout)
72
- setMaxListeners(Infinity, signal)
73
- signal.addEventListener('abort', () => {
74
- stream?.abort(new TimeoutError('ping timeout'))
75
- })
76
69
 
77
- const buf = await bytes.read({
78
- bytes: PING_LENGTH,
79
- signal
80
- })
81
- await bytes.write(buf, {
70
+ for await (const buf of stream) {
71
+ if (stream.status !== 'open') {
72
+ log('stream status changed to %s', stream.status)
73
+ break
74
+ }
75
+
76
+ if (!stream.send(buf)) {
77
+ log('waiting for stream to drain')
78
+ await pEvent(stream, 'drain', {
79
+ rejectionEvents: [
80
+ 'close'
81
+ ],
82
82
  signal
83
83
  })
84
-
85
- pinged = true
84
+ log('stream drained')
86
85
  }
87
- })
88
- .catch(err => {
89
- // ignore the error if we've processed at least one ping, the remote
90
- // closed the stream and we handled or are handling the close cleanly
91
- if (pinged && err.name === 'UnexpectedEOFError' && stream.readStatus !== 'ready') {
92
- return
93
- }
94
-
95
- log.error('ping from %p failed with error - %e', data.connection.remotePeer, err)
96
- stream?.abort(err)
97
- })
98
- .finally(() => {
99
- const ms = Date.now() - start
100
- log('ping from %p complete in %dms', data.connection.remotePeer, ms)
86
+ }
101
87
 
102
- const signal = AbortSignal.timeout(this.timeout)
103
- setMaxListeners(Infinity, signal)
88
+ log('ping from %p complete in %dms', connection.remotePeer, Date.now() - start)
104
89
 
105
- stream.close({
106
- signal
107
- })
108
- .catch(err => {
109
- log.error('error closing ping stream from %p - %e', data.connection.remotePeer, err)
110
- stream?.abort(err)
111
- })
112
- })
90
+ await stream.close({
91
+ signal
92
+ })
113
93
  }
114
94
 
115
95
  /**
116
96
  * Ping a given peer and wait for its response, getting the operation latency.
117
97
  */
118
98
  async ping (peer: PeerId | Multiaddr | Multiaddr[], options: AbortOptions = {}): Promise<number> {
119
- const start = Date.now()
120
99
  const data = randomBytes(PING_LENGTH)
121
- const connection = await this.components.connectionManager.openConnection(peer, options)
122
- const log = connection.log.newScope('ping')
123
- let stream: Stream | undefined
124
-
125
- if (options.signal == null) {
126
- const signal = AbortSignal.timeout(this.timeout)
127
-
128
- options = {
129
- ...options,
130
- signal
131
- }
132
- }
100
+ const stream = await this.components.connectionManager.openStream(peer, this.protocol, {
101
+ runOnLimitedConnection: this.runOnLimitedConnection,
102
+ ...options
103
+ })
104
+ const log = stream.log.newScope('ping')
133
105
 
134
106
  try {
135
- stream = await connection.newStream(this.protocol, {
136
- ...options,
137
- runOnLimitedConnection: this.runOnLimitedConnection
138
- })
139
-
140
- const bytes = byteStream(stream)
141
-
142
- const [, result] = await Promise.all([
143
- bytes.write(data, options),
144
- bytes.read({
145
- ...options,
146
- bytes: PING_LENGTH
147
- })
148
- ])
149
-
150
- const ms = Date.now() - start
151
-
152
- if (!uint8ArrayEquals(data, result.subarray())) {
153
- throw new ProtocolError(`Received wrong ping ack after ${ms}ms`)
107
+ const start = Date.now()
108
+ const finished = Promise.withResolvers<number>()
109
+ const received = new Uint8ArrayList()
110
+
111
+ const onPong = (evt: StreamMessageEvent): void => {
112
+ received.append(evt.data)
113
+
114
+ if (received.byteLength === PING_LENGTH) {
115
+ stream.removeEventListener('message', onPong)
116
+
117
+ const rtt = Date.now() - start
118
+
119
+ Promise.all([
120
+ stream.closeRead(options)
121
+ ])
122
+ .then(() => {
123
+ if (!uint8ArrayEquals(data, received.subarray())) {
124
+ throw new ProtocolError(`Received wrong ping ack after ${rtt}ms`)
125
+ } else {
126
+ finished.resolve(rtt)
127
+ }
128
+ })
129
+ .catch(err => {
130
+ stream.abort(err)
131
+ finished.reject(err)
132
+ })
133
+ }
154
134
  }
155
135
 
156
- log('ping %p complete in %dms', connection.remotePeer, ms)
136
+ stream.addEventListener('message', onPong)
137
+ stream.send(data)
138
+ await stream.close(options)
157
139
 
158
- return ms
140
+ return await raceSignal(finished.promise, options.signal)
159
141
  } catch (err: any) {
160
- log.error('error while pinging %p', connection.remotePeer, err)
142
+ log.error('error while pinging %o - %e', peer, err)
161
143
 
162
144
  stream?.abort(err)
163
145
 
164
146
  throw err
165
147
  } finally {
166
- if (stream != null) {
167
- await stream.close(options)
168
- }
148
+ stream?.close()
169
149
  }
170
150
  }
171
151
  }
@@ -1,15 +0,0 @@
1
- {
2
- "Ping": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.Ping.html",
3
- ".:Ping": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.Ping.html",
4
- "PingComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.PingComponents.html",
5
- ".:PingComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.PingComponents.html",
6
- "PingInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.PingInit.html",
7
- ".:PingInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_ping.PingInit.html",
8
- "PingService": "https://libp2p.github.io/js-libp2p/types/_libp2p_ping.PingService.html",
9
- ".:PingService": "https://libp2p.github.io/js-libp2p/types/_libp2p_ping.PingService.html",
10
- "PingServiceInit": "https://libp2p.github.io/js-libp2p/types/_libp2p_ping.PingServiceInit.html",
11
- ".:PingServiceInit": "https://libp2p.github.io/js-libp2p/types/_libp2p_ping.PingServiceInit.html",
12
- "PING_PROTOCOL": "https://libp2p.github.io/js-libp2p/variables/_libp2p_ping.PING_PROTOCOL.html",
13
- "ping": "https://libp2p.github.io/js-libp2p/functions/_libp2p_ping.ping.html",
14
- ".:ping": "https://libp2p.github.io/js-libp2p/functions/_libp2p_ping.ping.html"
15
- }