diff options
author | Florian Dold <florian@dold.me> | 2022-01-11 21:00:12 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-01-11 22:15:56 +0100 |
commit | a74cdf05295764258fe9e7f66f73a442a9b46697 (patch) | |
tree | d1a662fede130abc1fa33cdbc96c081cc47b23cd /packages/taler-wallet-core/src/headless | |
parent | a05e891d6e1468fdd99f710301e286857a46aea3 (diff) | |
download | wallet-core-a74cdf05295764258fe9e7f66f73a442a9b46697.tar.gz wallet-core-a74cdf05295764258fe9e7f66f73a442a9b46697.tar.bz2 wallet-core-a74cdf05295764258fe9e7f66f73a442a9b46697.zip |
fix DB indexing issues
Diffstat (limited to 'packages/taler-wallet-core/src/headless')
-rw-r--r-- | packages/taler-wallet-core/src/headless/helpers.ts | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts index 191c48441..d8616f716 100644 --- a/packages/taler-wallet-core/src/headless/helpers.ts +++ b/packages/taler-wallet-core/src/headless/helpers.ts @@ -37,6 +37,7 @@ import type { IDBFactory } from "@gnu-taler/idb-bridge"; import { WalletNotification } from "@gnu-taler/taler-util"; import { Wallet } from "../wallet.js"; import * as fs from "fs"; +import { AccessStats } from "@gnu-taler/idb-bridge/src/MemoryBackend"; const logger = new Logger("headless/helpers.ts"); @@ -80,6 +81,21 @@ function makeId(length: number): string { export async function getDefaultNodeWallet( args: DefaultNodeWalletArgs = {}, ): Promise<Wallet> { + const res = await getDefaultNodeWallet2(args); + return res.wallet; +} + +/** + * Get a wallet instance with default settings for node. + * + * Extended version that allows getting DB stats. + */ +export async function getDefaultNodeWallet2( + args: DefaultNodeWalletArgs = {}, +): Promise<{ + wallet: Wallet; + getDbStats: () => AccessStats; +}> { BridgeIDBFactory.enableTracing = false; const myBackend = new MemoryBackend(); myBackend.enableTracing = false; @@ -121,7 +137,7 @@ export async function getDefaultNodeWallet( BridgeIDBFactory.enableTracing = false; const myBridgeIdbFactory = new BridgeIDBFactory(myBackend); - const myIdbFactory: IDBFactory = (myBridgeIdbFactory as any) as IDBFactory; + const myIdbFactory: IDBFactory = myBridgeIdbFactory as any as IDBFactory; let myHttpLib; if (args.httpLib) { @@ -164,5 +180,8 @@ export async function getDefaultNodeWallet( if (args.notifyHandler) { w.addNotificationListener(args.notifyHandler); } - return w; + return { + wallet: w, + getDbStats: () => myBackend.accessStats, + }; } |