Interface IndexedTree

Indexed merkle tree.

interface IndexedTree {
    appendLeaves(leaves): Promise<void>;
    batchInsert(leaves, treeHeight, subtreeHeight, includeUncommitted): Promise<[LowLeafWitnessData[], BaseSiblingPath] | [undefined, BaseSiblingPath]>;
    commit(): Promise<void>;
    findIndexOfPreviousValue(newValue, includeUncommitted): {
        alreadyPresent: boolean;
        index: number;
    };
    getDepth(): number;
    getLatestLeafDataCopy(index, includeUncommitted): undefined | LeafData;
    getLeafValue(index, includeUncommitted): Promise<undefined | Field>;
    getNumLeaves(includeUncommitted): bigint;
    getRoot(includeUncommitted): Field;
    getSiblingPath(index, includeUncommitted): Promise<BaseSiblingPath>;
    rollback(): Promise<void>;
    updateLeaf(leaf, index): Promise<void>;
}

Hierarchy (view full)

Implemented by

Methods

  • Finds the index of the largest leaf whose value is less than or equal to the provided value.

    Parameters

    • newValue: bigint

      The new value to be inserted into the tree.

    • includeUncommitted: boolean

      If true, the uncommitted changes are included in the search.

    Returns {
        alreadyPresent: boolean;
        index: number;
    }

    The found leaf index and a flag indicating if the corresponding leaf's value is equal to newValue.

    • alreadyPresent: boolean

      A flag indicating if the corresponding leaf's value is equal to newValue.

    • index: number

      The index of the found leaf.

  • Gets the latest LeafData copy.

    Parameters

    • index: number

      Index of the leaf of which to obtain the LeafData copy.

    • includeUncommitted: boolean

      If true, the uncommitted changes are included in the search.

    Returns undefined | LeafData

    A copy of the leaf data at the given index or undefined if the leaf was not found.

  • Returns the value of a leaf at the specified index.

    Parameters

    • index: bigint

      The index of the leaf value to be returned.

    • includeUncommitted: boolean

      Set to true to include uncommitted updates in the data set.

    Returns Promise<undefined | Field>