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
leafβ
Returnsβ
StateBoundedMerkleTree
Throwsβ
If the index is out-of-bounds for the tree