Skip to main content

Module sync

Module sync 

Source
Expand description

Long-lived sync loop over moonproof_indexer_client::subscribe_contract_actions.

Subscribes to the indexer’s contractActions(address, offset) stream for a single contract and advances an in-memory ContractRuntimeState each tick via [moonproof_runtime::state::fold_contract_actions]. Exposes the latest state to callers via a tokio::sync::watch::Receiver — the canonical “subscribe once, observe many” pattern.

§Lifecycle

  • spawn returns a Watcher carrying:
  • The driver task runs until the subscription ends (server complete, network error, or caller cancelling via Watcher::abort).
  • Errors from the indexer subscription are surfaced via the driver’s Watcher::join result — consumers can either consult it or let the task run until it errors, whichever fits their app.

Structs§

Watcher
Handle returned by spawn — consumers pull state updates via watch() and can abort the driver via abort().

Functions§

spawn
Spawn a long-lived driver that replays + tails the indexer’s contractActions(address) stream and advances initial_state in-place. Returns a Watcher carrying the latest state and the driver’s join handle.