1 |
|
2 | import { DB, BatchDBOp } from './db';
|
3 | import type { LevelUp } from 'levelup';
|
4 | export declare type Checkpoint = {
|
5 | keyValueMap: Map<string, Buffer | null>;
|
6 | root: Buffer;
|
7 | };
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export declare class CheckpointDB extends DB {
|
13 | checkpoints: Checkpoint[];
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | constructor(leveldb?: LevelUp);
|
20 | /**
|
21 | * Is the DB during a checkpoint phase?
|
22 | */
|
23 | get isCheckpoint(): boolean;
|
24 | /**
|
25 | * Adds a new checkpoint to the stack
|
26 | * @param root
|
27 | */
|
28 | checkpoint(root: Buffer): void;
|
29 | /**
|
30 | * Commits the latest checkpoint
|
31 | */
|
32 | commit(): Promise<void>;
|
33 | /**
|
34 | * Reverts the latest checkpoint
|
35 | */
|
36 | revert(): Promise<Buffer>;
|
37 | /**
|
38 | * Retrieves a raw value from leveldb.
|
39 | * @param key
|
40 | * @returns A Promise that resolves to `Buffer` if a value is found or `null` if no value is found.
|
41 | */
|
42 | get(key: Buffer): Promise<Buffer | null>;
|
43 | /**
|
44 | * Writes a value directly to leveldb.
|
45 | * @param key The key as a `Buffer`
|
46 | * @param value The value to be stored
|
47 | */
|
48 | put(key: Buffer, val: Buffer): Promise<void>;
|
49 | /**
|
50 | * Removes a raw value in the underlying leveldb.
|
51 | * @param keys
|
52 | */
|
53 | del(key: Buffer): Promise<void>;
|
54 | /**
|
55 | * Performs a batch operation on db.
|
56 | * @param opStack A stack of levelup operations
|
57 | */
|
58 | batch(opStack: BatchDBOp[]): Promise<void>;
|
59 | }
|