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
  • Constructor Details

    • DeltaTree

      public DeltaTree​(Tree base, byte[] deltaNodes)
      Creates a new instance.
      Parameters:
      base - the base tree
      deltaNodes - new nodes of the tree. (Careful you don't create garbage.)
      See Also:
      computeNewLeafCount(Tree, byte[]), DeltaBuilder
    • DeltaTree

      protected DeltaTree​(DeltaTree copy)
      Copy constructor.
  • Method Details

    • computeNewLeafCount

      public static int computeNewLeafCount​(Tree base, byte[] deltaNodes) throws java.lang.IllegalArgumentException
      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:
      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 class Tree
      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).
      Specified by:
      leafWidth in class Tree