-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblock-storage.ts
58 lines (50 loc) · 1.89 KB
/
block-storage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { BlockHeader } from "../models/block-header";
/**
* Interface representing a block storage system.
*/
export interface BlockStorage {
/**
* Destroys the block storage, releasing any resources held.
* @returns A promise that resolves when the storage is destroyed.
*/
destroy(): Promise<void>;
/**
* Stores a single block header.
* @param block - The block header to store.
* @returns A promise that resolves when the block header is stored.
*/
put(block: BlockHeader): Promise<void>;
/**
* Stores multiple block headers.
* @param blocks - An array of block headers to store.
* @returns A promise that resolves when all block headers are stored.
*/
putMany(blocks: BlockHeader[]): Promise<void>;
/**
* Retrieves a block header by its hash.
* @param hash - The hash of the block header to retrieve.
* @returns A promise that resolves with the block header if found, or undefined if not found.
*/
getByHash(hash: string): Promise<BlockHeader | undefined>;
/**
* Retrieves a block header by its height.
* @param height - The height of the block header to retrieve.
* @returns A promise that resolves with the block header if found, or undefined if not found.
*/
getByHeight(height: number): Promise<BlockHeader | undefined>;
/**
* Retrieves all block headers.
* @returns A promise that resolves with an array of all block headers.
*/
getAll(): Promise<BlockHeader[]>;
/**
* Retrieves a backup of the block storage.
* @returns A promise that resolves with a 2D array representing the backup.
*/
getBackup(): Promise<number[][]>;
/**
* Retrieves the most recently synced block header.
* @returns A promise that resolves with the most recently synced block header, or undefined if none are synced.
*/
getSynced(): Promise<BlockHeader | undefined>;
}