@icgio/icg-exchanges-wrapper 1.21.19 → 1.21.21
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.
|
@@ -170,8 +170,17 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// Create WebSocket with ALL pairs collected in first pass
|
|
173
|
-
// This ensures only ONE WebSocket per exchange, even with multiple clients/pairs
|
|
174
|
-
|
|
173
|
+
// This ensures only ONE WebSocket per exchange, even with multiple clients/pairs.
|
|
174
|
+
// `first_time[Exchange_name]` gates the actual ws_market call so the WS is set
|
|
175
|
+
// up exactly once per process — every subsequent get_exchanges_rates poll
|
|
176
|
+
// re-enters this branch (because we no longer cache ws_promise below) but
|
|
177
|
+
// doesn't reopen the socket. The new ws_promise runs a fresh rate_ws cycle
|
|
178
|
+
// against the live `asks_dict`/`bids_dict` each time, which is the whole
|
|
179
|
+
// point of dropping the cache.
|
|
180
|
+
if (!first_time[Exchange_name]) {
|
|
181
|
+
Exchange.ws_market(all_pairs)
|
|
182
|
+
first_time[Exchange_name] = true
|
|
183
|
+
}
|
|
175
184
|
|
|
176
185
|
const WS_TIMEOUT_MS = 30000 // 30 seconds timeout
|
|
177
186
|
const MAX_CHECKS = 300 // 30 seconds / 100ms
|
|
@@ -316,12 +325,16 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
316
325
|
|
|
317
326
|
check_status()
|
|
318
327
|
})
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
|
|
328
|
+
// Do NOT cache this promise. `Exchange.rate_ws(pair, cb)` returns a SNAPSHOT
|
|
329
|
+
// of `asks_dict[pair]`/`bids_dict[pair]` at call time — for exchanges using
|
|
330
|
+
// ordered_dict (e.g. Bybit) `.entries().map(...)` creates a new array, and
|
|
331
|
+
// for exchanges using a plain-array depth (e.g. Mexc) every depth message
|
|
332
|
+
// REPLACES the array reference. Either way the result is frozen once the
|
|
333
|
+
// promise resolves. Rerunning the else branch each poll lets a new rate_ws
|
|
334
|
+
// call pick up changes the WebSocket has applied since last tick;
|
|
335
|
+
// `first_time[Exchange_name]` above prevents the underlying WS from being
|
|
336
|
+
// reopened, so there's no reconnect cost. Mirrors v1.17.27 (f815363) which
|
|
337
|
+
// fixed the same bug for get_exchanges_market_history.
|
|
325
338
|
}
|
|
326
339
|
|
|
327
340
|
// Wrap WebSocket promise to handle rejection and fall back to REST
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-exchanges-wrapper",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/icgio/icg-exchanges-wrapper#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@icgio/icg-exchanges": "^1.45.
|
|
20
|
+
"@icgio/icg-exchanges": "^1.45.11",
|
|
21
21
|
"@icgio/icg-utils": "^1.9.62",
|
|
22
22
|
"lodash": "^4.17.23",
|
|
23
23
|
"pg": "^8.17.2"
|