summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/state.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/state.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/state.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/operations/state.ts b/packages/taler-wallet-core/src/operations/state.ts
index 66baa95a4..ee7ceb8af 100644
--- a/packages/taler-wallet-core/src/operations/state.ts
+++ b/packages/taler-wallet-core/src/operations/state.ts
@@ -27,8 +27,13 @@ import { WalletStoresV1 } from "../db.js";
import { PendingOperationsResponse } from "../pending-types.js";
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo.js";
import { HttpRequestLibrary } from "../util/http";
-import { OpenedPromise, openPromise } from "../util/promiseUtils.js";
+import {
+ AsyncCondition,
+ OpenedPromise,
+ openPromise,
+} from "../util/promiseUtils.js";
import { DbAccess } from "../util/query.js";
+import { TimerGroup } from "../util/timer.js";
type NotificationListener = (n: WalletNotification) => void;
@@ -37,6 +42,9 @@ const logger = new Logger("state.ts");
export const EXCHANGE_COINS_LOCK = "exchange-coins-lock";
export const EXCHANGE_RESERVES_LOCK = "exchange-reserves-lock";
+/**
+ * Internal state of the wallet.
+ */
export class InternalWalletState {
memoProcessReserve: AsyncOpMemoMap<void> = new AsyncOpMemoMap();
memoMakePlanchet: AsyncOpMemoMap<void> = new AsyncOpMemoMap();
@@ -47,8 +55,15 @@ export class InternalWalletState {
memoProcessDeposit: AsyncOpMemoMap<void> = new AsyncOpMemoMap();
cryptoApi: CryptoApi;
+ timerGroup: TimerGroup = new TimerGroup();
+ latch = new AsyncCondition();
+ stopped = false;
+ memoRunRetryLoop = new AsyncOpMemoSingle<void>();
+
listeners: NotificationListener[] = [];
+ initCalled: boolean = false;
+
/**
* Promises that are waiting for a particular resource.
*/
@@ -86,6 +101,15 @@ export class InternalWalletState {
}
/**
+ * Stop ongoing processing.
+ */
+ stop(): void {
+ this.stopped = true;
+ this.timerGroup.stopCurrentAndFutureTimers();
+ this.cryptoApi.stop();
+ }
+
+ /**
* Run an async function after acquiring a list of locks, identified
* by string tokens.
*/