Small optimizations during rescanning and ChainTip()

This commit is contained in:
Duke Leto
2021-05-19 10:51:07 -04:00
parent d977345b26
commit 4db320355b

View File

@@ -480,13 +480,19 @@ void CWallet::ChainTip(const CBlockIndex *pindex,
pblock->GetBlockTime() > GetTime() - 144*ASSETCHAINS_BLOCKTIME) pblock->GetBlockTime() > GetTime() - 144*ASSETCHAINS_BLOCKTIME)
{ {
BuildWitnessCache(pindex, false); BuildWitnessCache(pindex, false);
RunSaplingConsolidation(pindex->GetHeight()); if (fSaplingConsolidationEnabled) {
DeleteWalletTransactions(pindex); RunSaplingConsolidation(pindex->GetHeight());
}
if (fTxDeleteEnabled) {
DeleteWalletTransactions(pindex);
}
} else { } else {
//Build initial witnesses on every block //Build initial witnesses on every block
BuildWitnessCache(pindex, true); BuildWitnessCache(pindex, true);
if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) { if (fTxDeleteEnabled) {
DeleteWalletTransactions(pindex); if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) {
DeleteWalletTransactions(pindex);
}
} }
} }
} else { } else {
@@ -1122,6 +1128,7 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly)
nd->witnessHeight = pblockindex->GetHeight(); nd->witnessHeight = pblockindex->GetHeight();
} }
} }
} }
} }
@@ -2734,8 +2741,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
BuildWitnessCache(pindex, true); BuildWitnessCache(pindex, true);
//Delete Transactions //Delete Transactions
if (pindex->GetHeight() % fDeleteInterval == 0) if (fTxDeleteEnabled) {
DeleteWalletTransactions(pindex); if (pindex->GetHeight() % fDeleteInterval == 0)
DeleteWalletTransactions(pindex);
}
if (GetTime() >= nNow + 60) { if (GetTime() >= nNow + 60) {
nNow = GetTime(); nNow = GetTime();