Conversation
Previously, `handle_delta` used `or_default()` which silently created uninitialized OrderbookState entries when deltas arrived before a snapshot. This produced corrupt partial books. Now deltas for unknown or uninitialized markets are dropped. The `initialized` field is removed from the public OrderbookSummary since the aggregator guarantees it only emits data for initialized books. Also narrows `Channel::requires_market_ticker()` to only OrderbookDelta and fixes minor style issues in examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OrderbookAggregator::handle_delta()now returns early when no snapshot has been received for a market, instead of calling.entry().or_default()which silently created empty uninitialized orderbook entries. This preventedfull_book()andtracked_markets()from returning stale/invalid data.initializedfield fromOrderbookSummarysince the aggregator now guarantees summaries are only produced for fully initialized orderbooks.Channel::requires_market_ticker()to only require tickers forOrderbookDelta— other market data channels support subscribing with an empty ticker list.Test plan
test_delta_before_snapshot_ignored— verifies deltas before a snapshot are silently dropped and no ghost entry is createdtest_full_book— verifiesfull_book()returns correct ladder after snapshot + delta applicationcargo test)