Merge #16774: Avoid unnecessary "Synchronizing blockheaders" log messages

dcc448e3d2b97f7e4e23f5ed174762cec3530306 Avoid unnecessary "Synchronizing blockheaders" log messages (Jonas Schnelli)

Pull request description:

  Fixes #16773

  I'm not entirely sure why 16773 happend, but probably due to headers fallback in a compact block.

  However, this PR should fix it and should have been included in #15615.

ACKs for top commit:
  ajtowns:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306 ; code review only, haven't compiled or tested.
  promag:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306.
  TheBlueMatt:
    utACK dcc448e3d2b97f7e4e23f5ed174762cec3530306. Went and read how pindexBestHeader is handled and this code looks correct (worst case it breaks a LogPrint, so whatever). I also ran into this on #16762.
  fanquake:
    ACK dcc448e3d2b97f7e4e23f5ed174762cec3530306

Tree-SHA512: f8cac3b6eb9d4e8fab53a535b55f9ea9b058e3ab6ade64801ebc56439ede4f54b5fee36d5d2b316966ab987b65b13ab9dc18849f345d08b81ecdf2722a3f5f5a
This commit is contained in:
MarcoFalke 2019-09-03 16:39:08 -04:00 committed by humbleDasher
parent 07af856ef1
commit 2996f593ef

View File

@ -3011,7 +3011,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
return true; return true;
} }
static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) { static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
bool fNotify = false; bool fNotify = false;
bool fInitialBlockDownload = false; bool fInitialBlockDownload = false;
static CBlockIndex* pindexHeaderOld = nullptr; static CBlockIndex* pindexHeaderOld = nullptr;
@ -3031,6 +3031,7 @@ static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
uiInterface.NotifyHeaderTip(fInitialBlockDownload, pindexHeader); uiInterface.NotifyHeaderTip(fInitialBlockDownload, pindexHeader);
GetMainSignals().NotifyHeaderTip(pindexHeader, fInitialBlockDownload); GetMainSignals().NotifyHeaderTip(pindexHeader, fInitialBlockDownload);
} }
return fNotify;
} }
static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) { static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) {
@ -4019,8 +4020,7 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
} }
} }
} }
NotifyHeaderTip(); if (NotifyHeaderTip()) {
{
LOCK(cs_main); LOCK(cs_main);
if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) { if (::ChainstateActive().IsInitialBlockDownload() && ppindex && *ppindex) {
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);