Skip to content

Commit 90ba2df

Browse files
committed
Fix missing cs_main lock for GuessVerificationProgress()
1 parent 6970b30 commit 90ba2df

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ size_t ClientModel::getMempoolDynamicUsage() const
138138
double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
139139
{
140140
CBlockIndex *tip = const_cast<CBlockIndex *>(tipIn);
141+
LOCK(cs_main);
141142
if (!tip)
142143
{
143-
LOCK(cs_main);
144144
tip = chainActive.Tip();
145145
}
146146
return GuessVerificationProgress(Params().TxData(), tip);

src/validation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4659,6 +4659,7 @@ bool DumpMempool(void)
46594659
}
46604660

46614661
//! Guess how far we are in the verification process at the given block index
4662+
//! require cs_main if pindex has not been validated yet (because nChainTx might be unset)
46624663
double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pindex) {
46634664
if (pindex == nullptr)
46644665
return 0.0;

src/wallet/wallet.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,20 +1673,15 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
16731673
dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex);
16741674
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
16751675
}
1676+
double gvp = dProgressStart;
16761677
while (pindex && !fAbortRescan)
16771678
{
16781679
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) {
1679-
double gvp = 0;
1680-
{
1681-
LOCK(cs_main);
1682-
gvp = GuessVerificationProgress(chainParams.TxData(), pindex);
1683-
}
16841680
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((gvp - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
16851681
}
16861682
if (GetTime() >= nNow + 60) {
16871683
nNow = GetTime();
1688-
LOCK(cs_main);
1689-
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
1684+
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, gvp);
16901685
}
16911686

16921687
CBlock block;
@@ -1710,6 +1705,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
17101705
{
17111706
LOCK(cs_main);
17121707
pindex = chainActive.Next(pindex);
1708+
gvp = GuessVerificationProgress(chainParams.TxData(), pindex);
17131709
if (tip != chainActive.Tip()) {
17141710
tip = chainActive.Tip();
17151711
// in case the tip has changed, update progress max
@@ -1718,7 +1714,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
17181714
}
17191715
}
17201716
if (pindex && fAbortRescan) {
1721-
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
1717+
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, gvp);
17221718
}
17231719
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
17241720
}

0 commit comments

Comments
 (0)