UNPKG

@chainsafe/persistent-merkle-tree

Version:

Merkle tree implemented as a persistent datastructure

23 lines (22 loc) 938 B
import { Gindex } from "./gindex.ts"; import { Node } from "./node.ts"; type Snapshot = { finalized: Uint8Array[]; count: number; }; /** * Given a tree, return a snapshot of the tree with the root, finalized nodes, and count. * Tree could be full tree, or partial tree. See https://github.com/ChainSafe/ssz/issues/293 */ export declare function toSnapshot(rootNode: Node, depth: number, count: number): Snapshot; /** * Given a snapshot, return root node of a tree. * See https://github.com/ChainSafe/ssz/issues/293 */ export declare function fromSnapshot(snapshot: Snapshot, depth: number): Node; /** * A finalized gindex means that the gindex is at the root of a subtree of the tree where there is no ZERO_NODE belong to it. * Given a list of depth `depth` and an index `index`, return a list of finalized gindexes. */ export declare function indexToFinalizedGindices(depth: number, index: number): Gindex[]; export {};