aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2018-01-28 09:15:18 -1000
committerJonas Schnelli <dev@jonasschnelli.ch>2018-01-30 17:49:22 -1000
commit90ba2df11b5bc943ac48b49b5da8023864dc842d (patch)
treeb5d52238deaabf843c6ee404fe7a632db3f20395
parent6970b30c6f1d2be7947295fe18f2390649b17a4b (diff)
downloadbitcoin-90ba2df11b5bc943ac48b49b5da8023864dc842d.tar.xz
Fix missing cs_main lock for GuessVerificationProgress()
-rw-r--r--src/qt/clientmodel.cpp2
-rw-r--r--src/validation.cpp1
-rw-r--r--src/wallet/wallet.cpp12
3 files changed, 6 insertions, 9 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 3642e5d4d4..eaf2896bc3 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -138,9 +138,9 @@ size_t ClientModel::getMempoolDynamicUsage() const
double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
{
CBlockIndex *tip = const_cast<CBlockIndex *>(tipIn);
+ LOCK(cs_main);
if (!tip)
{
- LOCK(cs_main);
tip = chainActive.Tip();
}
return GuessVerificationProgress(Params().TxData(), tip);
diff --git a/src/validation.cpp b/src/validation.cpp
index 8cee0dfac3..289313b55c 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4659,6 +4659,7 @@ bool DumpMempool(void)
}
//! 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)
return 0.0;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 07a23ce249..31894dff14 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1673,20 +1673,15 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
dProgressStart = 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(1, std::min(99, (int)((gvp - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
}
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;
@@ -1710,6 +1705,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
{
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
@@ -1718,7 +1714,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
}
}
if (pindex && fAbortRescan) {
- LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, GuessVerificationProgress(chainParams.TxData(), pindex));
+ LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, gvp);
}
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
}