Trie implements TxDb interface fully
This commit is contained in:
Vendored
+2
-2
@@ -21,6 +21,6 @@ export interface BaseDb {
|
||||
put (key: Uint8Array, value: Uint8Array): void;
|
||||
}
|
||||
|
||||
export interface TxDb extends BaseDb {
|
||||
transaction (fn: () => boolean): boolean;
|
||||
export interface TxDb <T = any> extends BaseDb {
|
||||
transaction (fn: () => boolean): T;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { TxDb } from '@polkadot/db/types';
|
||||
import { TxDb, ProgressCb } from '@polkadot/db/types';
|
||||
import { Node, NodeBranch, NodeEncodedOrEmpty, NodeKv, NodeNotEmpty, NodeType } from './types';
|
||||
|
||||
import MemoryDb from '@polkadot/db/Memory';
|
||||
@@ -20,7 +20,7 @@ import { EMPTY_HASH, EMPTY_U8A } from './constants';
|
||||
|
||||
const l = logger('trie/db');
|
||||
|
||||
export default class Trie {
|
||||
export default class Trie implements TxDb<Uint8Array> {
|
||||
private db: TxDb;
|
||||
private txRoot: Uint8Array;
|
||||
private rootHash: Uint8Array;
|
||||
@@ -61,6 +61,18 @@ export default class Trie {
|
||||
}
|
||||
}
|
||||
|
||||
open (): void {
|
||||
this.db.open();
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.db.close();
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
this.db.maintain(fn);
|
||||
}
|
||||
|
||||
del (key: Uint8Array) {
|
||||
l.debug(() => ['del', { key }]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user