MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / updateSymbolDepthCache

Method updateSymbolDepthCache

src/node-binance-api.ts:6497–6518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6495 };
6496
6497 const updateSymbolDepthCache = json => {
6498 // Get previous store symbol
6499 const symbol = json.symbol;
6500 // Initialize depth cache from snapshot
6501 this.depthCache[symbol] = this.depthData(json);
6502 // Prepare depth cache context
6503 const context = this.depthCacheContext[symbol];
6504 context.snapshotUpdateId = json.lastUpdateId;
6505 context.messageQueue = context.messageQueue.filter(depth => depth.u > context.snapshotUpdateId);
6506 // Process any pending depth messages
6507 for (const depth of context.messageQueue) {
6508 /* Although sync errors shouldn't ever happen here, we catch and swallow them anyway
6509 just in case. The stream handler function above will deal with broken caches. */
6510 try {
6511 this.depthHandler(depth);
6512 } catch (err) {
6513 // Do nothing
6514 }
6515 }
6516 delete context.messageQueue;
6517 if (callback) callback(symbol, this.depthCache[symbol]);
6518 };
6519
6520 /* If an array of symbols are sent we use a combined stream connection rather.
6521 This is transparent to the developer, and results in a single socket connection.

Callers

nothing calls this directly

Calls 2

depthDataMethod · 0.95
depthHandlerMethod · 0.95

Tested by

no test coverage detected