Summary
Implement an in-memory write-through cache for protocol current state during live ingestion, enabling efficient computation of additive state after handoff from migration.
Scope
- Per-protocol cache:
map[protocolID] -> { currentStateCursor, stateData }
- Empty at start: cache is unpopulated when live ingestion starts
- Populated from DB: on first successful CAS-advance of current_state_cursor (the handoff moment), read current state from protocol state tables (one-time DB read)
- Updated per ledger: on each subsequent ledger, update cache in-memory + write through to DB
- Lost on restart: if live ingestion restarts, cache is repopulated from DB on next current-state production
- Needed because additive state (e.g., token balances) requires knowing state at N-1 to compute state at N
Dependencies
Reference
docs/feature-design/data-migrations.md (State Production section, line 619+)
Summary
Implement an in-memory write-through cache for protocol current state during live ingestion, enabling efficient computation of additive state after handoff from migration.
Scope
map[protocolID] -> { currentStateCursor, stateData }Dependencies
Reference
docs/feature-design/data-migrations.md(State Production section, line 619+)