StateBoundedMerkleTree
@midnight-ntwrk/onchain-runtime v0.2.2 β’ Readme | API
@midnight-ntwrk/onchain-runtime v0.2.2 / StateBoundedMerkleTree
Class: StateBoundedMerkleTree
Represents a fixed-depth Merkle tree storing hashed data, whose preimages are unknown
Constructorsβ
new StateBoundedMerkleTree(height)β
new StateBoundedMerkleTree(height): StateBoundedMerkleTree
Create a blank tree with the given height
Parametersβ
β’ height: number
Returnsβ
Propertiesβ
heightβ
readonly height: number;
Methodsβ
collapse()β
Internal
collapse(start, end): StateBoundedMerkleTree
Erases all but necessary hashes between, and inclusive of, start and
end inidices
Parametersβ
β’ start: bigint
β’ end: bigint
Returnsβ
Throwsβ
If the indices are out-of-bounds for the tree, or end < start
findPathForLeaf()β
Internal
findPathForLeaf(leaf): AlignedValue
Internal implementation of the finding path primitive
Parametersβ
β’ leaf: AlignedValue
Returnsβ
Throwsβ
If the leaf is not in the tree
pathForLeaf()β
Internal
pathForLeaf(index, leaf): AlignedValue
Internal implementation of the path construction primitive
Parametersβ
β’ index: bigint
β’ leaf: AlignedValue
Returnsβ
Throwsβ
If the index is out-of-bounds for the tree
root()β
Internal
root(): Value
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: AlignedValue
Returnsβ
Throwsβ
If the index is out-of-bounds for the tree