#30637·ccxt

mexc: `watchOrderBook` 在 REST 快照落入缓冲推送内时会默默丢失更新 - `getCacheIndex` 和 `handleDelta` 比较 `fromVersion`, 而 MEXC 则指定 `toVersion`

作者: VascoSPires创建于 2026年9月25日更新于 2026年9月25日
标签bugws

ts/src/pro/mexc.ts:

typescript
override getCacheIndex (orderbook: any, cache: any): number {
    const nonce = this.safeInteger (orderbook, 'nonce');
    const firstDelta = this.safeDict (cache, 0);
    const firstDeltaNonce = this.safeIntegerN (firstDelta, [ 'r', 'version', 'fromVersion' ]);
    if ((nonce === undefined) || (firstDeltaNonce === undefined)) {
        return -1;
    }
    if (nonce < firstDeltaNonce - 1) {
        return -1;
    }
    for (let i = 0; i < cache.length; i++) {
        const delta = cache[i];
        const deltaNonce = this.safeIntegerN (delta, [ 'r', 'version', 'fromVersion' ]);
        if (deltaNonce === undefined) {
            continue;
        }
        if (deltaNonce >= nonce) {        // <-- selects on fromVersion
            return i;
        }
    }
    return cache.length;
}

override handleDelta (orderbook: any, delta: any) {
    const existingNonce = this.safeInteger (orderbook, 'nonce');
    const deltaNonce =
…