Package io.crums.util.mrkl
Class DeltaTree
java.lang.Object
io.crums.util.mrkl.Tree
io.crums.util.mrkl.DeltaTree
public class DeltaTree extends Tree
A Merkle tree constructed from another with more leaves appended. The "delta" in
the name refers not to deletions, but to the fact the data added and computed is
incremental even when the base tree is arbitrarily large.
- See Also:
DeltaBuilder
-
Field Summary
Fields inherited from class io.crums.util.mrkl.Tree
BRANCH_PAD, LEAF_PAD
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description static int
computeNewLeafCount(Tree base, byte[] deltaNodes)
Infers and returns the number of leaves in the new tree given an array of deltas (additions) from a base tree.byte[]
data(int level, int index)
Returns [a copy of] the data for the node at the specified coordinates.int
leafWidth()
Returns the leaf width in bytes if fixed; -1, otherwise (variable).Methods inherited from class io.crums.util.mrkl.Tree
appendToStringDetail, getHashAlgo, hash, hashAlgoWidth, hashInternals, hashLeaves, hashUncommon, idx, isLeafWidthFixed, isOmniWidth, proof, root, toString, verify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
DeltaTree
Creates a new instance.- Parameters:
base
- the base treedeltaNodes
- new nodes of the tree. (Careful you don't create garbage.)- See Also:
computeNewLeafCount(Tree, byte[])
,DeltaBuilder
-
DeltaTree
Copy constructor.
-
-
Method Details
-
computeNewLeafCount
public static int computeNewLeafCount(Tree base, byte[] deltaNodes) throws java.lang.IllegalArgumentExceptionInfers and returns the number of leaves in the new tree given an array of deltas (additions) from a base tree.- Parameters:
base
- an omni-width base tree (expected to be large)deltaNodes
- data array of length that is a multiple of Tree.hashAlgoWidth()- Returns:
- the new number of leaves
- Throws:
java.lang.IllegalArgumentException
-
data
public byte[] data(int level, int index)Description copied from class:Tree
Returns [a copy of] the data for the node at the specified coordinates.- Specified by:
data
in classTree
- See Also:
Node.data()
,#data(int, int, ByteBuffer)
-
leafWidth
public int leafWidth()Description copied from class:Tree
Returns the leaf width in bytes if fixed; -1, otherwise (variable).
-