Skip to content

Commit 40377c5

Browse files
codez0mb1eCopilot
andauthored
Repair checking for missed updates
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 64b3a5b commit 40377c5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/BinanceBot.Market/MarketDepthManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ private void ApplyDepthUpdate(MarketDepth marketDepth, IBinanceEventOrderBook ev
317317
_logger.Debug($"Ignoring old event: u={lastUpdateId} <= local={_localOrderBookUpdateId}");
318318
return;
319319
}
320+
// Critical validation: check for missed updates
321+
if (eventData.FirstUpdateId > _localOrderBookUpdateId + 1)
322+
{
323+
_logger.Error($"Missed updates! Expected U <= {_localOrderBookUpdateId + 1}, got U={eventData.FirstUpdateId}");
324+
throw new InvalidOperationException(
325+
$"Missed order book updates. Expected U <= {_localOrderBookUpdateId + 1}, got {eventData.FirstUpdateId}. " +
326+
"Local order book is out of sync. Please restart the process.");
327+
}
320328

321329
// 2. Update price levels
322330
if (_localOrderBookUpdateId % 100 == 0) // Log every 100th update to avoid flooding

0 commit comments

Comments
 (0)