StateDB¶
Description¶
StateDB handles storage and modification of the local verified state. StateDB is frequently used by StateManager to keep track of the known state and to verify incoming transactions.
API¶
Structs¶
VerifiedStateUpdate¶
interface VerifiedStateUpdate {
start: number
end: number
verifiedBlockNumber: number
stateUpdate: StateUpdate
}
Description¶
Represents a StateUpdate that has been correctly verified up to a specific block. verifiedBlockNumber is updated whenever a non-inclusion proof implicitly demonstrates that the given state update is valid for verifiedBlockNumber + 1.
Fields¶
start-number: Start of the range for which this state update is still valid.end-number: End of the range for which this state update is still valid.verifiedBlockNumber-number: Plasma block number up to which this state update has been verified.stateUpdate-StateUpdate: Full original state update.
Methods¶
getVerifiedStateUpdates¶
async function getVerifiedStateUpdates(start: number, end: number): Promise<VerifiedStateUpdate[]>
Description¶
Pulls all VerifiedStateUpdate objects such that the range described by start and end intersects with the VerifiedStateUpdate. Intersection MUST be computed as start-inclusive and end-exclusive, i.e. (start, end].
Parameters¶
start-number: Start of the range to query.end-number: End of the range to query.
Returns¶
Promise<VerifiedStateUpdate[]>: List of VerifiedStateUpdate objects that intersect with the given range.
putVerifiedStateUpdate¶
async function putVerifiedStateUpdate(
verifiedStateUpdate: VerifiedStateUpdate
): Promise<void>
Description¶
Adds a new VerifiedStateUpdate object to the database. Overwrites, modifies, or breaks apart any existing objects in the database that intersect with the given one.
Parameters¶
verifiedStateUpdate-VerifiedStateUpdate: TheVerifiedStateUpdateobject to insert into the database.
Returns¶
Promise<void>: Promise that resolves once the object has been added to the database.