aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet.ts')
-rw-r--r--src/wallet.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wallet.ts b/src/wallet.ts
index a89d2d567..32a92cee0 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -248,6 +248,31 @@ export class Wallet {
n.type === NotificationType.WaitingForRetry &&
n.numGivingLiveness == 0
) {
+ logger.trace("no liveness-giving operations left, returning");
+ resolve();
+ }
+ });
+ this.runRetryLoop().catch(e => {
+ console.log("exception in wallet retry loop");
+ reject(e);
+ });
+ });
+ await p;
+ }
+
+ /**
+ * Run the wallet until there are no more pending operations that give
+ * liveness left. The wallet will be in a stopped state when this function
+ * returns without resolving to an exception.
+ */
+ public async runUntilDoneAndStop(): Promise<void> {
+ const p = new Promise((resolve, reject) => {
+ // Run this asynchronously
+ this.addNotificationListener(n => {
+ if (
+ n.type === NotificationType.WaitingForRetry &&
+ n.numGivingLiveness == 0
+ ) {
logger.trace("no liveness-giving operations left, stopping");
this.stop();
}