From c5ff945504aecc8c8bc5e283e74447170132a31c Mon Sep 17 00:00:00 2001 From: Rohan Jadvani <5459049+rohanjadvani@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:10:34 -0400 Subject: [PATCH] fix(ironfish): Guard event loop when the wallet is locked (#5393) --- ironfish/src/wallet/wallet.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ironfish/src/wallet/wallet.ts b/ironfish/src/wallet/wallet.ts index d3ff8da34c..b961bf8a02 100644 --- a/ironfish/src/wallet/wallet.ts +++ b/ironfish/src/wallet/wallet.ts @@ -308,18 +308,20 @@ export class Wallet { const [promise, resolve] = PromiseUtils.split() this.eventLoopPromise = promise - if (!this.scanner.running) { - void this.scan() - } + if (!this.locked) { + if (!this.scanner.running) { + void this.scan() + } - void this.syncTransactionGossip() - await this.cleanupDeletedAccounts() + void this.syncTransactionGossip() + await this.cleanupDeletedAccounts() - const head = await this.getLatestHead() + const head = await this.getLatestHead() - if (head) { - await this.expireTransactions(head.sequence) - await this.rebroadcastTransactions(head.sequence) + if (head) { + await this.expireTransactions(head.sequence) + await this.rebroadcastTransactions(head.sequence) + } } if (this.isStarted) {