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

dcc448e3d2 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 dcc448e3d2 ; code review only, haven't compiled or tested.
  promag:
    ACK dcc448e3d2.
  TheBlueMatt:
    utACK dcc448e3d2. 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 dcc448e3d2

Tree-SHA512: f8cac3b6eb9d4e8fab53a535b55f9ea9b058e3ab6ade64801ebc56439ede4f54b5fee36d5d2b316966ab987b65b13ab9dc18849f345d08b81ecdf2722a3f5f5a
This commit is contained in:
MarcoFalke 2019-09-03 16:39:08 -04:00
commit 8e00a68552
No known key found for this signature in database
GPG key ID: D2EA4850E7528B25

View file

@ -2557,7 +2557,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar
return true;
}
static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
static bool NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
bool fNotify = false;
bool fInitialBlockDownload = false;
static CBlockIndex* pindexHeaderOld = nullptr;
@ -2576,6 +2576,7 @@ static void NotifyHeaderTip() LOCKS_EXCLUDED(cs_main) {
if (fNotify) {
uiInterface.NotifyHeaderTip(fInitialBlockDownload, pindexHeader);
}
return fNotify;
}
static void LimitValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main) {
@ -3396,8 +3397,7 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidatio
}
}
}
NotifyHeaderTip();
{
if (NotifyHeaderTip()) {
LOCK(cs_main);
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);