wallet: skip fully validated txs before the depth lookup in the root selection
The root selection of VerifyAndSetInitialWitness looked up the depth of every note-bearing tx on every block, although in the steady state between restarts every note is already validated and nothing is selected. A tx whose notes are all validated is now skipped before GetDepthInMainChain. The selection is the same: it never took a validated note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1450,7 +1450,15 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO
|
||||
// surfaces exactly where it used to.
|
||||
std::vector<const SaplingNoteData*> rootNotes;
|
||||
for (const std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
if (wtxItem.second.mapSaplingNoteData.empty() || wtxItem.second.GetDepthInMainChain() <= 0)
|
||||
// Once every note is validated (the steady state between restarts) nothing here selects one, so
|
||||
// skip the depth lookup for such a tx.
|
||||
bool fAnyUnvalidated = false;
|
||||
for (const mapSaplingNoteData_t::value_type& item : wtxItem.second.mapSaplingNoteData)
|
||||
if (!item.second.witnessRootValidated) {
|
||||
fAnyUnvalidated = true;
|
||||
break;
|
||||
}
|
||||
if (!fAnyUnvalidated || wtxItem.second.GetDepthInMainChain() <= 0)
|
||||
continue;
|
||||
for (const mapSaplingNoteData_t::value_type& item : wtxItem.second.mapSaplingNoteData) {
|
||||
const SaplingNoteData* nd = &(item.second);
|
||||
|
||||
Reference in New Issue
Block a user