Skip to content

Commit

Permalink
fix: deleting account from remote node during rescan caused crash. Er…
Browse files Browse the repository at this point in the history
…ror was that in memory store still contained account for a moment while the head was deleted. (#4867)
  • Loading branch information
jowparks committed Apr 3, 2024
1 parent 4dc57d7 commit a34552c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ironfish/src/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ export class Wallet {
})

this.accounts.set(account.id, account)
this.logger.debug(`Account ${account.id} imported successfully`)
this.onAccountImported.emit(account)

return account
Expand All @@ -1646,6 +1647,7 @@ export class Wallet {
id: uuid(),
walletDb: this.walletDb,
})
this.logger.debug(`Resetting account name: ${account.name}, id: ${account.id}`)

await this.walletDb.db.withTransaction(options?.tx, async (tx) => {
await this.walletDb.setAccount(newAccount, tx)
Expand All @@ -1672,6 +1674,7 @@ export class Wallet {
}

async removeAccount(account: Account, tx?: IDatabaseTransaction): Promise<void> {
this.accounts.delete(account.id)
await this.walletDb.db.withTransaction(tx, async (tx) => {
if (account.id === this.defaultAccount) {
await this.walletDb.setDefaultAccount(null, tx)
Expand All @@ -1682,7 +1685,7 @@ export class Wallet {
await this.walletDb.removeHead(account, tx)
})

this.accounts.delete(account.id)
this.logger.debug(`Removed account name: ${account.name}, id: ${account.id}`)
this.onAccountRemoved.emit(account)
}

Expand Down

0 comments on commit a34552c

Please sign in to comment.