MerkleIntervalTree¶
Description¶
Our plasma implementation uses a special Merkle tree called a Merkle Interval Tree. This page describes the interface for an implementation of the tree.
API¶
Structs¶
MerkleIntervalTreeLeafNode¶
interface MerkleIntervalTreeLeafNode {
start: number
end: number
data: string
}
Description¶
Represents a leaf node in the tree.
Fields¶
start-number: Start of the range this leaf node covers.end-number: End of the range this leaf node covers.data-string: Arbitrary data held by the leaf node.
Methods¶
getInclusionProof¶
function getInclusionProof(
leaf: MerkleIntervalTreeLeafNode
): Promise<MerkleIntervalTreeInternalNode[]>
Description¶
Generates an inclusion proof for a given leaf node.
Parameters¶
leaf-MerkleIntervalTreeLeafNode: Leaf node to generate a proof for.
Returns¶
MerkleIntervalTreeInternalNode[]: List of internal nodes that form the inclusion proof.
checkInclusionProof¶
function checkInclusionProof(
leaf: MerkleIntervalTreeLeafNode,
leafIndex: number,
root: MerkleIntervalTreeInternalNode,
inclusionProof: MerkleIntervalTreeInternalNode[]
): boolean
Description¶
Checks an inclusion proof for a given leaf node.
Parameters¶
leaf-MerkleIntervalTreeLeafNode: Leaf node to check inclusion for.leafIndex-number: Index of the leaf node in the list of leaf nodes.root-MerkleIntervalTreeInternalNode: Root of the Merkle Interval Tree.inclusionProof-MerkleIntervalTreeInternalNode[]: List of internal nodes that form the inclusion proof.
Returns¶
boolean: true if the proof is valid, false otherwise.