Trackers API
Each Tracker exposes tracker-specific APIs to access the state it maintains.
⚙️ IMPLEMENTATION
Tracker reference implementation.
Trackers can access the Ledger via a restricted interface called ledgerForTracker
,
which grants access to the Ledger’s SQLite database, recent blocks, and other read-only
functionality.
In the other direction, the Ledger communicates with Trackers using the ledgerTracker
interface, which includes the following key methods:
-
loadFromDisk(ledgerForTracker)
Initializes the state of the Tracker. The Tracker can use theledgerForTracker
argument to:- Load persistent state (e.g., for the accounts database),
- Query recent blocks, if its state depends only on recent history (e.g., the one that tracks recently committed transactions).
-
newBlock(rnd, delta)
Notifies the Tracker of a newly added block at roundrnd
. The accompanyingdelta
parameter contains the state changes introduced by this block (see block evaluation section). -
committedUpTo(rnd)
Informs the Tracker that all blocks up to and includingrnd
are written to persistent storage. This call is crucial for stateful trackers, as it ensures correct state recovery and enables responses to queries about older blocks if recent uncommitted ones are lost after a crash. -
close()
Releases any resources or memory held by the Tracker.
The reference implementation ensures that all updates to Trackers are thread-safe using a reader-writer lock.