From 4db320355b6408e4dbec91ba825eeebd1eb31880 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 19 May 2021 10:51:07 -0400 Subject: [PATCH] Small optimizations during rescanning and ChainTip() --- src/wallet/wallet.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0a848ff33..b72e96386 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -480,13 +480,19 @@ void CWallet::ChainTip(const CBlockIndex *pindex, pblock->GetBlockTime() > GetTime() - 144*ASSETCHAINS_BLOCKTIME) { BuildWitnessCache(pindex, false); - RunSaplingConsolidation(pindex->GetHeight()); - DeleteWalletTransactions(pindex); + if (fSaplingConsolidationEnabled) { + RunSaplingConsolidation(pindex->GetHeight()); + } + if (fTxDeleteEnabled) { + DeleteWalletTransactions(pindex); + } } else { //Build initial witnesses on every block BuildWitnessCache(pindex, true); - if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) { - DeleteWalletTransactions(pindex); + if (fTxDeleteEnabled) { + if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) { + DeleteWalletTransactions(pindex); + } } } } else { @@ -1122,6 +1128,7 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) nd->witnessHeight = pblockindex->GetHeight(); } } + } } @@ -2734,8 +2741,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) BuildWitnessCache(pindex, true); //Delete Transactions - if (pindex->GetHeight() % fDeleteInterval == 0) - DeleteWalletTransactions(pindex); + if (fTxDeleteEnabled) { + if (pindex->GetHeight() % fDeleteInterval == 0) + DeleteWalletTransactions(pindex); + } if (GetTime() >= nNow + 60) { nNow = GetTime();