HistoryManager¶
Description¶
HistoryManager
is a wrapper around HistoryDB that provides easy access to specific historical data. HistoryManager
handles things like generating history proofs, creating inclusion proofs, and inserting historical state updates.
We’ve separated HistoryManager
from HistoryDB
to avoid coupling the underlying data storage with more complex queries.
API¶
Methods¶
getHistoryProof¶
async function getHistoryProof(
start: number,
end: number,
startBlock: number,
endBlock: number,
plasmaContract: string
): Promise<HistoryProof>
Description¶
Generates a proof for the history of a given range of state objects. Only returns the history for a specified block range so that a user with a known state doesn’t need to receive a significant amount of duplicate information.
Parameters¶
start
-number
: Start of the range of state objects to query.end
-number
: End of the range of state objects to query.startBlock
-number
: Block number to start querying history from.endBlock
-number
: Block number to query history to.plasmaContract
-string
: Address of the specific plasma contract to query.
Returns¶
HistoryProof
: A HistoryProof composed of proof elements that, when applied sequentially, build a valid history for the given range.
getInclusionProof¶
function getInclusionProof(
stateUpdate: StateUpdate
): Promise<InclusionProof>
Description¶
Generates an inclusion proof for a given state update. Creates a proof for both the upper-level address tree and the lower-level state tree. Will throw an error if the client does not have enough information to generate the proof.
Parameters¶
stateUpdate
-StateUpdate
: TheStateUpdate
object to generate an inclusion proof for.
Returns¶
InclusionProof
: An InclusionProof
that contains Merkle Interval Tree inclusion proofs for both the address tree and the state tree.