Skip to content

Commit

Permalink
inlines logic of setNoteHashSequence (#5643)
Browse files Browse the repository at this point in the history
remove setNoteHashSequence from the walletDb and moves the logic inline into
saveDecryptedNote; the only method that called setNoteHashSequence
  • Loading branch information
hughy authored Nov 13, 2024
1 parent dc683ca commit 6532166
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions ironfish/src/wallet/walletdb/walletdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,22 +589,6 @@ export class WalletDB {
)
}

async setNoteHashSequence(
account: Account,
noteHash: Buffer,
sequence: number | null,
tx?: IDatabaseTransaction,
): Promise<void> {
await this.db.withTransaction(tx, async (tx) => {
if (sequence) {
await this.sequenceToNoteHash.put([account.prefix, [sequence, noteHash]], null, tx)
await this.nonChainNoteHashes.del([account.prefix, noteHash], tx)
} else {
await this.nonChainNoteHashes.put([account.prefix, noteHash], null, tx)
}
})
}

async disconnectNoteHashSequence(
account: Account,
noteHash: Buffer,
Expand Down Expand Up @@ -840,7 +824,12 @@ export class WalletDB {
await this.saveNullifierNoteHash(account, note.nullifier, noteHash, tx)
}

await this.setNoteHashSequence(account, noteHash, note.sequence, tx)
if (note.sequence) {
await this.sequenceToNoteHash.put([account.prefix, [note.sequence, noteHash]], null, tx)
await this.nonChainNoteHashes.del([account.prefix, noteHash], tx)
} else {
await this.nonChainNoteHashes.put([account.prefix, noteHash], null, tx)
}

await this.decryptedNotes.put([account.prefix, noteHash], note, tx)
})
Expand Down

0 comments on commit 6532166

Please sign in to comment.