Skip to content

Commit

Permalink
Performance: speed-up 'z_getbalance' and 'z_sendmany' by 10x
Browse files Browse the repository at this point in the history
Skip note which has been spent and locked notes before decrypting
  • Loading branch information
MarkLTZ committed Jul 31, 2024
1 parent 9e02190 commit 6b8ad2f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5217,6 +5217,16 @@ void CWallet::GetFilteredNotes(
SaplingOutPoint op = pair.first;
SaplingNoteData nd = pair.second;

// skip note which has been spent
if (ignoreSpent && nd.nullifier && IsSaplingSpent(*nd.nullifier)) {
continue;
}

// skip locked notes
if (ignoreLocked && IsLockedNote(op)) {
continue;
}

auto maybe_pt = SaplingNotePlaintext::decrypt(
wtx.vShieldedOutput[op.n].encCiphertext,
nd.ivk,
Expand All @@ -5234,20 +5244,11 @@ void CWallet::GetFilteredNotes(
continue;
}

if (ignoreSpent && nd.nullifier && IsSaplingSpent(*nd.nullifier)) {
continue;
}

// skip notes which cannot be spent
if (requireSpendingKey && !HaveSpendingKeyForPaymentAddress(this)(pa)) {
continue;
}

// skip locked notes
if (ignoreLocked && IsLockedNote(op)) {
continue;
}

auto note = notePt.note(nd.ivk).value();
saplingEntries.push_back(SaplingNoteEntry {
op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() });
Expand Down

0 comments on commit 6b8ad2f

Please sign in to comment.