@dashevo/dapi-client 4.1.1 → 4.2.0-dev.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.
|
@@ -8,6 +8,8 @@ const EVENTS = {
|
|
|
8
8
|
ERROR: 'error',
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
const CLIENT_ALREADY_CLOSED_ERROR_MESSAGE = 'Client already closed - cannot .close()';
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* @typedef BlockHeadersReaderOptions
|
|
13
15
|
* @property {number} [maxParallelStreams]
|
|
@@ -132,8 +134,9 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
132
134
|
* @param e
|
|
133
135
|
*/
|
|
134
136
|
const rejectHeaders = async (e) => {
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
+
// Cancel the transport only: the retry below needs the listeners, so
|
|
138
|
+
// this cannot go through cancelStream, which unsubscribes from events
|
|
139
|
+
this.cancelStreamTransport(stream);
|
|
137
140
|
stream.retryOnError(e);
|
|
138
141
|
};
|
|
139
142
|
|
|
@@ -294,9 +297,25 @@ class BlockHeadersReader extends EventEmitter {
|
|
|
294
297
|
}
|
|
295
298
|
|
|
296
299
|
// eslint-disable-next-line class-methods-use-this
|
|
300
|
+
/**
|
|
301
|
+
* Cancels the stream's transport, tolerating one the transport has already
|
|
302
|
+
* closed. Listeners are left in place for callers that keep using the stream.
|
|
303
|
+
* @param {ReconnectableStream} stream
|
|
304
|
+
*/
|
|
305
|
+
// eslint-disable-next-line class-methods-use-this
|
|
306
|
+
cancelStreamTransport(stream) {
|
|
307
|
+
try {
|
|
308
|
+
stream.cancel();
|
|
309
|
+
} catch (e) {
|
|
310
|
+
if (e.message !== CLIENT_ALREADY_CLOSED_ERROR_MESSAGE) {
|
|
311
|
+
throw e;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
297
316
|
cancelStream(stream) {
|
|
298
317
|
stream.removeAllListeners();
|
|
299
|
-
|
|
318
|
+
this.cancelStreamTransport(stream);
|
|
300
319
|
}
|
|
301
320
|
}
|
|
302
321
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-dev.2",
|
|
4
4
|
"description": "Client library used to access Dash DAPI endpoints",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dashevo/dapi-grpc": "4.
|
|
30
|
-
"@dashevo/dash-spv": "5.
|
|
29
|
+
"@dashevo/dapi-grpc": "4.2.0-dev.2",
|
|
30
|
+
"@dashevo/dash-spv": "5.2.0-dev.2",
|
|
31
31
|
"@dashevo/dashcore-lib": "~0.22.0",
|
|
32
|
-
"@dashevo/grpc-common": "4.
|
|
33
|
-
"@dashevo/wasm-dpp": "4.
|
|
32
|
+
"@dashevo/grpc-common": "4.2.0-dev.2",
|
|
33
|
+
"@dashevo/wasm-dpp": "4.2.0-dev.2",
|
|
34
34
|
"cbor": "^8.0.0",
|
|
35
35
|
"google-protobuf": "^3.12.2",
|
|
36
36
|
"undici": "^6.0.0",
|