HistoryDB¶
Description¶
HistoryDB provides a simple interface to the set of historical StateUpdate objects. HistoryDB also stores all values necessary to prove the history of a given state object, including the Merkle Interval Tree inclusion proofs for each state update and the transactions that created those state updates.
API¶
Methods¶
getStateUpdate¶
async function getStateUpdate(
stateUpdateHash: string
): Promise<StateUpdate>
Description¶
Queries a full state update from the hash of the state update.
Returns¶
Promise<StateUpdate>: Full state update that corresponds to the given hash.
putStateUpdate¶
async function putStateUpdate(stateUpdate: StateUpdate): Promise<void>
Description¶
Adds a state update to the database.
Parameters¶
stateUpdate-StateUpdate: StateUpdate to add to the database.
Returns¶
Promise<void>: Promise that resolves once the state update has been added to the database.
getStateUpdateTransactions¶
getStateUpdateTransactions(
stateUpdateHash: string
): Promise<Transaction[]>
Description¶
Queries the list of Transaction objects that created the given state update.
Returns¶
Promise<Transaction[]>: List of Transaction objects that created the given state update.
putStateUpdateTransactions¶
async function putStateUpdateTransactions(
stateUpdateHash: string,
transactions: Transaction[]
): Promise<void>
Description¶
Stores the set of transactions that created a given state update.
Parameters¶
stateUpdateHash-string: keccak256 hash of the state update to set transactions for.transactions-Transaction[]: List of transactions that created the given state update.
Returns¶
Promise<void>: Promise that resolves once the transactions have been stored.
getStateUpdateLeafPosition¶
async function getStateUpdateLeafPosition(
stateUpdateHash: string
): Promise<number>
Description¶
Gets the leaf position of a given state update within the Merkle Interval Tree of the block in which the state update was included.
Returns¶
Promise<number>: Leaf position of the given state update.
putStateUpdateLeafPosition¶
async function putStateUpdateLeafPosition(
stateUpdateHash: string,
leafPosition: number
): Promise<void>
Description¶
Sets the leaf position for a given state update within the Merkle Interval Tree of the block in which the state update was included.
Parameters¶
stateUpdateHash-string: keccak256 hash of the state update.leafPosition-number: Leaf position for the state update.
Returns¶
Promise<void>: Promise that resolves once the leaf position has been set.
getBlockStateUpdateCount¶
async funtion getBlockStateUpdateCount(
block: number
): Promise<number>
Description¶
Gets the number of state updates that occurred within a given block.
Parameters¶
block-number: Block to query.
Returns¶
Promise<number>: Number of state updates that occurred within the given block.
putBlockStateUpdateCount¶
async function putBlockStateUpdateCount(
block: number,
stateUpdateCount: number
): Promise<void>
Description¶
Sets the number of state updates that were included within a given block.
Parameters¶
block-number: Block to set a count for.stateUpdateCount-number: Number of state updates included within the specified block.
Returns¶
Promise<void>: Promise that resolves once the state update count has been stored.
getStateTreeNode¶
async function getStateTreeNode(
block: number,
nodeIndex: number
): Promise<MerkleIntervalStateTreeNode>
Description¶
Queries a node in the state tree.
Parameters¶
block-number: Block for which to query a node.nodeIndex-number: Index of the node to query.
Returns¶
Promise<MerkleIntervalStateTreeNode>: The MerkleIntervalStateTreeNode at the given block and node index.
putStateTreeNode¶
async function putStateTreeNode(
block: number,
nodeIndex: number,
node: MerkleIntervalStateTreeNode
): Promise<void>
Description¶
Adds a node to the state tree for a given block.
Parameters¶
block-number: Block to add a state tree node for.nodeIndex-number: Index of the node to insert.node-MerkleIntervalStateTreeNode: State tree node to add to the tree.
Returns¶
Promise<void>: Promise that resolves once the node has been inserted into the tree.
getAddressTreeNode¶
async function getAddressTreeNode(
block: number,
nodeIndex: number
): Promise<MerkleIntervalAddressTreeNode>
Description¶
Gets a node in the address tree of a given block.
Parameters¶
block-number: Block for which to query an address tree node.nodeIndex-number: Index of the node to query.
Returns¶
Promise<MerkleIntervalAddressTreeNode>: The MerkleIntervalAddressTreeNode at the given index for the specified block.
putAddressTreeNode¶
async function putAddressTreeNode(
block: number,
nodeIndex: number,
node: MerkleIntervalAddressTreeNode
): Promise<void>
Description¶
Sets a node in the address tree of a given block.
Parameters¶
block-number: Block for which to set an address tree node.nodeIndex-number: Index of the node in the address tree.node-MerkleIntervalAddressTreeNode: Node to insert into the tree.
Returns¶
Promise<void>: Promise that resolves once the node has been added to the tree.