@pioneer-platform/blockbook 8.38.19 → 8.38.20
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +7 -0
- package/lib/BlockbookWebSocket.d.ts +1 -0
- package/lib/BlockbookWebSocket.js +26 -4
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @pioneer-platform/blockbook@8.38.
|
|
3
|
+
> @pioneer-platform/blockbook@8.38.20 build /Users/highlander/WebstormProjects/keepkey-stack/projects/pioneer/modules/intergrations/blockbook
|
|
4
4
|
> tsc -p .
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -45,6 +45,7 @@ export declare class BlockbookWebSocket extends EventEmitter {
|
|
|
45
45
|
private pendingRequests;
|
|
46
46
|
private subscriptions;
|
|
47
47
|
private methodToId;
|
|
48
|
+
private recentlyRemovedIds;
|
|
48
49
|
private perMessageDeflate;
|
|
49
50
|
constructor(url: string, options?: {
|
|
50
51
|
perMessageDeflate?: boolean;
|
|
@@ -77,6 +77,9 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
77
77
|
_this.subscriptions = new Map();
|
|
78
78
|
// Track subscription method to ID mapping (only one subscription per method)
|
|
79
79
|
_this.methodToId = new Map();
|
|
80
|
+
// Track recently-removed subscription IDs to suppress UNKNOWN MESSAGE spam
|
|
81
|
+
// IDs stay here for 60s after removal to absorb in-flight notifications
|
|
82
|
+
_this.recentlyRemovedIds = new Map(); // id -> removal timestamp
|
|
80
83
|
_this.url = url;
|
|
81
84
|
_this.perMessageDeflate = (_a = options === null || options === void 0 ? void 0 : options.perMessageDeflate) !== null && _a !== void 0 ? _a : true;
|
|
82
85
|
return _this;
|
|
@@ -202,8 +205,12 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
202
205
|
}
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
205
|
-
//
|
|
206
|
-
|
|
208
|
+
// Check if this is a stale subscription ID (recently removed during subscription replacement or reconnect)
|
|
209
|
+
if (this.recentlyRemovedIds.has(id)) {
|
|
210
|
+
return; // Silently drop — expected during subscription transitions
|
|
211
|
+
}
|
|
212
|
+
// Truly unknown message
|
|
213
|
+
console.warn("[BlockbookWebSocket] Unknown message ID: ".concat(id));
|
|
207
214
|
this.emit('unknown-message', message);
|
|
208
215
|
};
|
|
209
216
|
BlockbookWebSocket.prototype.request = function (method, params, providedId) {
|
|
@@ -253,6 +260,7 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
253
260
|
oldId = this.methodToId.get(method);
|
|
254
261
|
if (oldId) {
|
|
255
262
|
this.subscriptions.delete(oldId);
|
|
263
|
+
this.recentlyRemovedIds.set(oldId, Date.now()); // grace period for in-flight notifications
|
|
256
264
|
}
|
|
257
265
|
id = (this.requestCounter++).toString();
|
|
258
266
|
// Store subscription with the pre-incremented ID
|
|
@@ -288,6 +296,7 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
288
296
|
return [2 /*return*/, { subscribed: false }];
|
|
289
297
|
}
|
|
290
298
|
this.subscriptions.delete(id);
|
|
299
|
+
this.recentlyRemovedIds.set(id, Date.now()); // grace period for in-flight notifications
|
|
291
300
|
this.methodToId.delete(method);
|
|
292
301
|
return [2 /*return*/, this.request('unsubscribeAddresses', {})];
|
|
293
302
|
});
|
|
@@ -304,6 +313,7 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
304
313
|
oldId = this.methodToId.get(method);
|
|
305
314
|
if (oldId) {
|
|
306
315
|
this.subscriptions.delete(oldId);
|
|
316
|
+
this.recentlyRemovedIds.set(oldId, Date.now()); // grace period for in-flight notifications
|
|
307
317
|
}
|
|
308
318
|
id = (this.requestCounter++).toString();
|
|
309
319
|
// Store subscription with the pre-incremented ID
|
|
@@ -339,6 +349,7 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
339
349
|
return [2 /*return*/, { subscribed: false }];
|
|
340
350
|
}
|
|
341
351
|
this.subscriptions.delete(id);
|
|
352
|
+
this.recentlyRemovedIds.set(id, Date.now()); // grace period for in-flight notifications
|
|
342
353
|
this.methodToId.delete(method);
|
|
343
354
|
return [2 /*return*/, this.request('unsubscribeNewBlock', {})];
|
|
344
355
|
});
|
|
@@ -378,12 +389,18 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
378
389
|
this.stopPing();
|
|
379
390
|
// Ping every 25 seconds to keep connection alive
|
|
380
391
|
this.pingInterval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
381
|
-
var error_3;
|
|
392
|
+
var cutoff_1, error_3;
|
|
393
|
+
var _this = this;
|
|
382
394
|
var _a;
|
|
383
395
|
return __generator(this, function (_b) {
|
|
384
396
|
switch (_b.label) {
|
|
385
397
|
case 0:
|
|
386
398
|
_b.trys.push([0, 2, , 3]);
|
|
399
|
+
cutoff_1 = Date.now() - 60000;
|
|
400
|
+
this.recentlyRemovedIds.forEach(function (ts, id) {
|
|
401
|
+
if (ts < cutoff_1)
|
|
402
|
+
_this.recentlyRemovedIds.delete(id);
|
|
403
|
+
});
|
|
387
404
|
return [4 /*yield*/, this.ping()];
|
|
388
405
|
case 1:
|
|
389
406
|
_b.sent();
|
|
@@ -428,7 +445,8 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
428
445
|
jitter = Math.random() * 1000;
|
|
429
446
|
this.emit('reconnecting', { attempt: this.reconnectAttempts, delay: delay });
|
|
430
447
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
431
|
-
var subsToRestore, _i, subsToRestore_1, sub, error_4;
|
|
448
|
+
var now_1, subsToRestore, _i, subsToRestore_1, sub, error_4;
|
|
449
|
+
var _this = this;
|
|
432
450
|
return __generator(this, function (_a) {
|
|
433
451
|
switch (_a.label) {
|
|
434
452
|
case 0:
|
|
@@ -436,6 +454,10 @@ var BlockbookWebSocket = /** @class */ (function (_super) {
|
|
|
436
454
|
return [4 /*yield*/, this.connect()];
|
|
437
455
|
case 1:
|
|
438
456
|
_a.sent();
|
|
457
|
+
now_1 = Date.now();
|
|
458
|
+
this.subscriptions.forEach(function (_, id) {
|
|
459
|
+
_this.recentlyRemovedIds.set(id, now_1);
|
|
460
|
+
});
|
|
439
461
|
subsToRestore = Array.from(this.subscriptions.values());
|
|
440
462
|
this.subscriptions.clear();
|
|
441
463
|
this.methodToId.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/blockbook",
|
|
3
|
-
"version": "8.38.
|
|
3
|
+
"version": "8.38.20",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"request-promise-native": "^1.0.9",
|
|
16
16
|
"ws": "^8.18.0",
|
|
17
17
|
"@pioneer-platform/loggerdog": "8.11.0",
|
|
18
|
+
"@pioneer-platform/pioneer-nodes": "8.37.11",
|
|
18
19
|
"@pioneer-platform/pioneer-caip": "9.27.10",
|
|
19
|
-
"@pioneer-platform/pioneer-nodes": "8.37.10",
|
|
20
20
|
"@pioneer-platform/utxo-crypto": "8.11.0"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|