diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5695,6 +5695,8 @@ } //! Guess how far we are in the verification process at the given block index +//! require cs_main if pindex has not been validated yet (because nChainTx might +//! be unset) double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex) { if (pindex == nullptr) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1758,15 +1758,10 @@ GuessVerificationProgress(chainParams.TxData(), pindex); dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip); } + double gvp = dProgressStart; while (pindex && !fAbortRescan) { if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) { - double gvp = 0; - { - LOCK(cs_main); - gvp = - GuessVerificationProgress(chainParams.TxData(), pindex); - } ShowProgress( _("Rescanning..."), std::max( @@ -1776,11 +1771,8 @@ } if (GetTime() >= nNow + 60) { nNow = GetTime(); - LOCK(cs_main); - LogPrintf( - "Still rescanning. At block %d. Progress=%f\n", - pindex->nHeight, - GuessVerificationProgress(chainParams.TxData(), pindex)); + LogPrintf("Still rescanning. At block %d. Progress=%f\n", + pindex->nHeight, gvp); } CBlock block; @@ -1807,6 +1799,7 @@ { LOCK(cs_main); pindex = chainActive.Next(pindex); + gvp = GuessVerificationProgress(chainParams.TxData(), pindex); if (tip != chainActive.Tip()) { tip = chainActive.Tip(); // in case the tip has changed, update progress max @@ -1818,8 +1811,7 @@ if (pindex && fAbortRescan) { LogPrintf("Rescan aborted at block %d. Progress=%f\n", - pindex->nHeight, - GuessVerificationProgress(chainParams.TxData(), pindex)); + pindex->nHeight, gvp); } // Hide progress dialog in GUI.