-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtxo-storage.ts
159 lines (139 loc) · 5.48 KB
/
txo-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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import type { TxLog } from "../services/inv-service";
import type { Ingest, IngestStatus } from "../models/ingest";
import type { Outpoint } from "../models/outpoint";
import type { TxoLookup, TxoResults, TxoSort } from "../models/search";
import type { Txo } from "../models/txo";
/**
* Interface representing a storage system for transaction outputs (Txo).
*/
export interface TxoStorage {
/**
* Destroys the storage, cleaning up any resources.
* @returns A promise that resolves when the operation is complete.
*/
destroy(): Promise<void>;
/**
* Retrieves a transaction output by its outpoint.
* @param outpoint - The outpoint of the transaction output.
* @returns A promise that resolves to the transaction output or undefined if not found.
*/
get(outpoint: Outpoint): Promise<Txo | undefined>;
/**
* Retrieves multiple transaction outputs by their outpoints.
* @param outpoints - An array of outpoints.
* @returns A promise that resolves to an array of transaction outputs or undefined if not found.
*/
getMany(outpoints: Outpoint[]): Promise<(Txo | undefined)[]>;
/**
* Retrieves transaction outputs by the transaction ID that spent them.
* @param txid - The transaction ID.
* @returns A promise that resolves to an array of transaction outputs.
*/
getBySpend(txid: string): Promise<Txo[]>;
/**
* Stores a transaction output.
* @param txo - The transaction output to store.
* @returns A promise that resolves when the operation is complete.
*/
put(txo: Txo): Promise<void>;
/**
* Stores multiple transaction outputs.
* @param txos - An array of transaction outputs to store.
* @returns A promise that resolves when the operation is complete.
*/
putMany(txos: Txo[]): Promise<void>;
/**
* Searches for transaction outputs based on a lookup criteria.
* @param lookup - The lookup criteria.
* @param sort - Optional sorting criteria.
* @param limit - Optional limit on the number of results.
* @param from - Optional starting point for the search.
* @returns A promise that resolves to the search results.
*/
search(lookup: TxoLookup, sort?: TxoSort, limit?: number, from?: string): Promise<TxoResults>;
/**
* Retrieves a state value by its key.
* @param key - The key of the state value.
* @returns A promise that resolves to the state value or undefined if not found.
*/
getState(key: string): Promise<string | undefined>;
/**
* Sets a state value by its key.
* @param key - The key of the state value.
* @param value - The value to set.
* @returns A promise that resolves when the operation is complete.
*/
setState(key: string, value: string): Promise<void>;
/**
* Retrieves the length of the queue.
* @returns A promise that resolves to the length of the queue.
*/
getQueueLength(): Promise<number>;
/**
* Retrieves ingests based on their status.
* @param status - The status of the ingests.
* @param limit - The maximum number of ingests to retrieve.
* @param start - Optional starting point for the retrieval.
* @param stop - Optional stopping point for the retrieval.
* @returns A promise that resolves to an array of ingests.
*/
getIngests(
status: IngestStatus,
limit: number,
start?: number,
stop?: number,
): Promise<Ingest[]>;
/**
* Stores an ingest.
* @param ingest - The ingest to store.
* @returns A promise that resolves when the operation is complete.
*/
putIngest(ingest: Ingest): Promise<void>;
/**
* Stores multiple ingests.
* @param ingests - An array of ingests to store.
* @returns A promise that resolves when the operation is complete.
*/
putIngests(ingests: Ingest[]): Promise<void>;
/**
* Deletes an ingest by its transaction ID.
* @param txid - The transaction ID of the ingest to delete.
* @returns A promise that resolves when the operation is complete.
*/
delIngest(txid: string): Promise<void>;
/**
* Deletes multiple ingests by their transaction IDs.
* @param txids - An array of transaction IDs of the ingests to delete.
* @returns A promise that resolves when the operation is complete.
*/
delIngests(txids: string[]): Promise<void>;
/**
* Retrieves a transaction log by its transaction ID.
* @param txid - The transaction ID of the log to retrieve.
* @returns A promise that resolves to the transaction log or undefined if not found.
*/
getTxLog(txid: string): Promise<TxLog | undefined>;
/**
* Retrieves multiple transaction logs by their transaction IDs.
* @param txids - An array of transaction IDs of the logs to retrieve.
* @returns A promise that resolves to an array of transaction logs or undefined if not found.
*/
getTxLogs(txids: string[]): Promise<(TxLog | undefined)[]>;
/**
* Retrieves recent transaction logs.
* @param limit - Optional limit on the number of logs to retrieve.
* @returns A promise that resolves to an array of recent transaction logs.
*/
getRecentTxLogs(limit?: number): Promise<TxLog[]>;
/**
* Stores a transaction log.
* @param txLog - The transaction log to store.
* @returns A promise that resolves when the operation is complete.
*/
putTxLog(txLog: TxLog): Promise<void>;
/**
* Retrieves backup logs.
* @returns A promise that resolves to an array of backup logs.
*/
getBackupLogs(): Promise<Ingest[]>;
}