Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,743 Lines • ▼ Show 20 Lines | try { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
//! Guess how far we are in the verification process at the given block index | //! 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 | //! require cs_main if pindex has not been validated yet (because nChainTx might | ||||
//! be unset) | //! be unset) | ||||
//! This conditional lock requirement might be confusing, see: | |||||
//! https://github.com/bitcoin/bitcoin/issues/15994 | |||||
double GuessVerificationProgress(const ChainTxData &data, | double GuessVerificationProgress(const ChainTxData &data, | ||||
const CBlockIndex *pindex) { | const CBlockIndex *pindex) { | ||||
if (pindex == nullptr) { | if (pindex == nullptr) { | ||||
return 0.0; | return 0.0; | ||||
} | } | ||||
// This function assumes the lock on cs_main is already held (see the | |||||
// above comment). This is a temporary check until PR15997 is backported. | |||||
// https://github.com/bitcoin/bitcoin/pull/15997 | |||||
AssertLockHeld(cs_main); | |||||
int64_t nNow = time(nullptr); | int64_t nNow = time(nullptr); | ||||
double fTxTotal; | double fTxTotal; | ||||
if (pindex->nChainTx <= data.nTxCount) { | if (pindex->nChainTx <= data.nTxCount) { | ||||
fTxTotal = data.nTxCount + (nNow - data.nTime) * data.dTxRate; | fTxTotal = data.nTxCount + (nNow - data.nTime) * data.dTxRate; | ||||
} else { | } else { | ||||
fTxTotal = | fTxTotal = | ||||
pindex->nChainTx + (nNow - pindex->GetBlockTime()) * data.dTxRate; | pindex->nChainTx + (nNow - pindex->GetBlockTime()) * data.dTxRate; | ||||
Show All 17 Lines |