UNPKG

1.36 kBTypeScriptView Raw
1import { Trie as BaseTrie } from './baseTrie';
2import { CheckpointDB } from './checkpointDb';
3/**
4 * Adds checkpointing to the {@link BaseTrie}
5 */
6export declare class CheckpointTrie extends BaseTrie {
7 db: CheckpointDB;
8 constructor(...args: any);
9 /**
10 * Is the trie during a checkpoint phase?
11 */
12 get isCheckpoint(): boolean;
13 /**
14 * Creates a checkpoint that can later be reverted to or committed.
15 * After this is called, all changes can be reverted until `commit` is called.
16 */
17 checkpoint(): void;
18 /**
19 * Commits a checkpoint to disk, if current checkpoint is not nested.
20 * If nested, only sets the parent checkpoint as current checkpoint.
21 * @throws If not during a checkpoint phase
22 */
23 commit(): Promise<void>;
24 /**
25 * Reverts the trie to the state it was at when `checkpoint` was first called.
26 * If during a nested checkpoint, sets root to most recent checkpoint, and sets
27 * parent checkpoint as current.
28 */
29 revert(): Promise<void>;
30 /**
31 * Returns a copy of the underlying trie with the interface of CheckpointTrie.
32 * @param includeCheckpoints - If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
33 */
34 copy(includeCheckpoints?: boolean): CheckpointTrie;
35}