@icgio/icg-exchanges-wrapper 1.21.21 → 1.21.22
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.
|
@@ -156,11 +156,12 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
156
156
|
ws_promise_with_fallback = ws_connection_promises_with_fallback[ws_key]
|
|
157
157
|
}
|
|
158
158
|
} else {
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
// Re-enter this branch every poll (we no longer cache ws_promise below) so
|
|
160
|
+
// a fresh rate_ws cycle runs against the live asks_dict/bids_dict each time.
|
|
161
|
+
// `first_time[Exchange_name]` gates the actual ws_market call so the WS is
|
|
162
|
+
// set up exactly once per process — the "Creating connection" log lives
|
|
163
|
+
// inside that gate so it only fires on the genuine one-shot setup, not on
|
|
164
|
+
// every 30s poll.
|
|
164
165
|
ws_connection_pairs[ws_key] = all_pairs
|
|
165
166
|
ws_promise = new Promise((resolve, reject) => {
|
|
166
167
|
if (!Exchange.ws || !Exchange.ws.market) {
|
|
@@ -169,15 +170,10 @@ const get_exchanges_rates = function (Exchanges, exchange_pair_dict, cb, ws_enab
|
|
|
169
170
|
return
|
|
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
|
-
// `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
173
|
if (!first_time[Exchange_name]) {
|
|
174
|
+
if (all_pairs.length > 0) {
|
|
175
|
+
console.log(`[WebSocket Rates] ${Exchange_name}: Creating connection with ${all_pairs.length} pair(s): ${all_pairs.join(', ')}`)
|
|
176
|
+
}
|
|
181
177
|
Exchange.ws_market(all_pairs)
|
|
182
178
|
first_time[Exchange_name] = true
|
|
183
179
|
}
|