Skip to content

Commit 6532166

Browse files
authored
inlines logic of setNoteHashSequence (#5643)
remove setNoteHashSequence from the walletDb and moves the logic inline into saveDecryptedNote; the only method that called setNoteHashSequence
1 parent dc683ca commit 6532166

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

ironfish/src/wallet/walletdb/walletdb.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -589,22 +589,6 @@ export class WalletDB {
589589
)
590590
}
591591

592-
async setNoteHashSequence(
593-
account: Account,
594-
noteHash: Buffer,
595-
sequence: number | null,
596-
tx?: IDatabaseTransaction,
597-
): Promise<void> {
598-
await this.db.withTransaction(tx, async (tx) => {
599-
if (sequence) {
600-
await this.sequenceToNoteHash.put([account.prefix, [sequence, noteHash]], null, tx)
601-
await this.nonChainNoteHashes.del([account.prefix, noteHash], tx)
602-
} else {
603-
await this.nonChainNoteHashes.put([account.prefix, noteHash], null, tx)
604-
}
605-
})
606-
}
607-
608592
async disconnectNoteHashSequence(
609593
account: Account,
610594
noteHash: Buffer,
@@ -840,7 +824,12 @@ export class WalletDB {
840824
await this.saveNullifierNoteHash(account, note.nullifier, noteHash, tx)
841825
}
842826

843-
await this.setNoteHashSequence(account, noteHash, note.sequence, tx)
827+
if (note.sequence) {
828+
await this.sequenceToNoteHash.put([account.prefix, [note.sequence, noteHash]], null, tx)
829+
await this.nonChainNoteHashes.del([account.prefix, noteHash], tx)
830+
} else {
831+
await this.nonChainNoteHashes.put([account.prefix, noteHash], null, tx)
832+
}
844833

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

0 commit comments

Comments
 (0)