Class DeltaTree
java.lang.Object
io.crums.util.mrkl.Tree
io.crums.util.mrkl.DeltaTree
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:
-
Field Summary
Fields inherited from class io.crums.util.mrkl.Tree
BRANCH_PAD, LEAF_PAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcomputeNewLeafCount(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.intReturns the leaf width in bytes if fixed; -1, otherwise (variable).Methods inherited from class io.crums.util.mrkl.Tree
appendToStringDetail, getHashAlgo, hash, hashAlgoWidth, hashInternals, hashInternals, hashLeaves, hashLeaves, hashUncommon, hashUncommon, idx, isLeafWidthFixed, isOmniWidth, proof, root, toString
-
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:
-
DeltaTree
Copy constructor.
-
-
Method Details
-
computeNewLeafCount
Infers 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:
IllegalArgumentException
-
data
public byte[] data(int level, int index) Description copied from class:TreeReturns [a copy of] the data for the node at the specified coordinates. For internal nodes, this is just the node's hash, which is computed from the hash of its child nodes; for leaf nodes, the node's data may generally be anything, but more often than not it's the hash of a source object. -
leafWidth
-