StateBoundedMerkleTree
@midnight-ntwrk/compact-runtime v0.9.0
@midnight-ntwrk/compact-runtime / StateBoundedMerkleTree
Class: StateBoundedMerkleTree
Represents a fixed-depth Merkle tree storing hashed data, whose preimages are unknown
Constructors
Constructor
new StateBoundedMerkleTree(height): StateBoundedMerkleTree;
Create a blank tree with the given height
Parameters
height
number
Returns
StateBoundedMerkleTree
Properties
height
readonly height: number;
Methods
collapse()
collapse(start, end): StateBoundedMerkleTree;
Internal
Erases all but necessary hashes between, and inclusive of, start and
end inidices
Parameters
start
bigint
end
bigint
Returns
StateBoundedMerkleTree
Throws
If the indices are out-of-bounds for the tree, or end < start
findPathForLeaf()
findPathForLeaf(leaf): AlignedValue;
Internal
Internal implementation of the finding path primitive
Parameters
leaf
Returns
Throws
If the leaf is not in the tree
pathForLeaf()
pathForLeaf(index, leaf): AlignedValue;
Internal
Internal implementation of the path construction primitive
Parameters
index
bigint
leaf
Returns
Throws
If the index is out-of-bounds for the tree
root()
root(): Value;
Internal
Internal implementation of the merkle tree root primitive
Returns
toString()
toString(compact?): string;
Parameters
compact?
boolean
Returns
string
update()
update(index, leaf): StateBoundedMerkleTree;
Inserts a value into the Merkle tree, returning the updated tree
Parameters
index
bigint