Expand description
Persistent engine state snapshots for fast restart recovery.
After journal replay the engine writes a snapshot of its core state
(orderbooks, counters, expired instruments) to disk. On the next
restart the snapshot is loaded first, and only the delta since the
snapshotβs last_command_id needs to be replayed from the journal.
File format: [msgpack payload][4-byte CRC32 LE]
Atomic write: temp β fsync β rename (same as journal checkpoint writes).
StructsΒ§
- Engine
State Snapshot - Persistent engine state snapshot for fast restart recovery.
- Legacy
Engine πState Snapshot - Pre-CALL-1707 snapshot layout without
last_balance_update_seq. - Legacy
Engine πState Snapshot PreAppend Only V2 - Older v2 layout from before snapshot fields were made append-only.
- Order
Snapshot Entry - A single order in the snapshot, matching
OrderBook::get_all_orders()output. - Volatility
Surface Snapshot
ConstantsΒ§
- LEGACY_
BALANCE_ πUPDATE_ SEQ_ MIGRATION_ EPOCH - LEGACY_
SNAPSHOT_ πVERSION_ V1 - LEGACY_
SNAPSHOT_ πVERSION_ V2 - SNAPSHOT_
CRC π - SNAPSHOT_
VERSION π - Current snapshot format version.
FunctionsΒ§
- build_
snapshot - Build a snapshot from current engine state, tagged with the checkpoint boundary.
- decode_
legacy_ πengine_ state_ snapshot - msgpack_
array_ πstart - msgpack_
map_ πstart - msgpack_
str_ πat - msgpack_
u32_ πat - read_
snapshot - Read a snapshot from disk with CRC32 integrity verification.
- snapshot_
order_ count - Count total orders across all orderbooks in a snapshot.
- snapshot_
path_ from_ wal_ path - Derive the snapshot file path from the WAL path.
- snapshot_
payload_ πversion - write_
snapshot - Write a snapshot atomically: temp β fsync β rename β dir sync.