Skip to content

Centralize engine_seq minting through next_engine_seq() (#73)#84

Merged
joaquinbejar merged 1 commit intomainfrom
issue-73-engine-seq-mint
Apr 25, 2026
Merged

Centralize engine_seq minting through next_engine_seq() (#73)#84
joaquinbejar merged 1 commit intomainfrom
issue-73-engine-seq-mint

Conversation

@joaquinbejar
Copy link
Copy Markdown
Owner

Summary

  • Convert process_level_match from a static function to a method on OrderBook<T>.
  • The matching emission path now calls self.next_engine_seq() directly instead of going through a private mint_engine_seq() helper, removing the duplicate fetch_add site that issue Refactor matching loop to centralize engine_seq minting #73 flagged.
  • next_engine_seq() is now the single source of truth and inlines fetch_add(1, Relaxed).
  • process_level_match() loses 5 parameters now that it can read last_trade_price, has_traded, price_level_changed_listener, engine_seq, and risk_state from &self.

Closes #73.

Test plan

  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --all --check
  • cargo test --all-features — 1125 passed, 0 failed
  • cargo build --release --all-features

…_seq()

Convert process_level_match from a static function to a method on
OrderBook<T>. The matching emission path now calls
self.next_engine_seq() directly instead of going through a private
mint_engine_seq() helper, eliminating the duplicate fetch_add site
that issue #73 flagged.

- Drop the pub(super) mint_engine_seq() free function from book.rs.
- next_engine_seq() inlines fetch_add(1, Relaxed) and is now the
  single source of truth for sequence allocation.
- process_level_match() loses 5 parameters now that it can read
  last_trade_price, has_traded, price_level_changed_listener,
  engine_seq, and risk_state from &self.

Closes #73.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes engine_seq minting by making OrderBook::next_engine_seq() the only place that performs the fetch_add(1, Relaxed), and updates the matching emission path to call that method directly (addressing issue #73’s duplication concern).

Changes:

  • Convert process_level_match from a static helper into an OrderBook<T> method so it can read needed state from &self.
  • Remove the mint_engine_seq() helper and inline its fetch_add(1, Relaxed) logic into next_engine_seq().
  • Route price-level change event stamping through self.next_engine_seq() from within process_level_match.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/orderbook/matching.rs Makes process_level_match a method and routes engine sequence stamping through next_engine_seq().
src/orderbook/book.rs Removes mint_engine_seq() and makes next_engine_seq() the single minting site by inlining the atomic increment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@joaquinbejar joaquinbejar merged commit 26dd8b2 into main Apr 25, 2026
17 checks passed
@joaquinbejar joaquinbejar deleted the issue-73-engine-seq-mint branch April 25, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor matching loop to centralize engine_seq minting

2 participants