aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-05-16 00:17:03 +0200
committerFlorian Dold <florian@dold.me>2024-05-16 00:17:06 +0200
commit0dc3e3a2affd71f33e9fbe9c19ca8dd6c3589e15 (patch)
tree4edab219bfb8326e39d4aa3d195b77f3eb5c27c5 /packages/taler-wallet-core/src/wallet.ts
parent80a6a2f29bd1b43fd1ca14aeb3fa34e823b0e38a (diff)
downloadwallet-core-0dc3e3a2affd71f33e9fbe9c19ca8dd6c3589e15.tar.xz
wallet-core: for most CLI commands, start task loop lazily
We don't want potential network activity when we just check the status of transactions, look at the balance, etc.
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index b8ef4976d..b232080e9 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -742,7 +742,6 @@ async function dispatchRequestInternal(
innerError: getErrorDetailFromException(e),
});
}
-
wex.ws.initWithConfig(applyRunConfigDefaults(req.config));
if (wex.ws.config.testing.skipDefaults) {
@@ -755,8 +754,11 @@ async function dispatchRequestInternal(
versionInfo: getVersion(wex),
};
- // After initialization, task loop should run.
- await wex.taskScheduler.ensureRunning();
+ if (req.config?.features?.lazyTaskLoop) {
+ logger.trace("lazily starting task loop");
+ } else {
+ await wex.taskScheduler.ensureRunning();
+ }
wex.ws.initCalled = true;
return resp;
@@ -1623,6 +1625,14 @@ async function handleCoreApiRequest(
id: string,
payload: unknown,
): Promise<CoreApiResponse> {
+ if (operation !== WalletApiOperation.InitWallet) {
+ if (!ws.initCalled) {
+ throw Error("init must be called first");
+ }
+ // Might be lazily initialized!
+ await ws.taskScheduler.ensureRunning();
+ }
+
let wex: WalletExecutionContext;
let oc: ObservabilityContext;
@@ -1702,6 +1712,7 @@ export function applyRunConfigDefaults(
},
features: {
allowHttp: wcp?.features?.allowHttp ?? false,
+ lazyTaskLoop: false,
},
testing: {
denomselAllowLate: wcp?.testing?.denomselAllowLate ?? false,
@@ -1821,7 +1832,7 @@ class WalletDbTriggerSpec implements TriggerSpec {
if (info.mode !== "readwrite") {
return;
}
- logger.info(
+ logger.trace(
`in after commit callback for readwrite, modified ${j2s([
...info.modifiedStores,
])}`,