diff --git a/src/validation.cpp b/src/validation.cpp index d8e83003a..3cdc9be64 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2610,7 +2610,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar return true; } -static void NotifyHeaderTip() { +static bool NotifyHeaderTip() { bool fNotify = false; bool fInitialBlockDownload = false; static CBlockIndex* pindexHeaderOld = nullptr; @@ -2629,6 +2629,7 @@ static void NotifyHeaderTip() { if (fNotify) { uiInterface.NotifyHeaderTip(fInitialBlockDownload, pindexHeader); } + return fNotify; } /** @@ -3401,7 +3402,12 @@ bool ProcessNewBlockHeaders(const std::vector& headers, CValidatio } } } - NotifyHeaderTip(); + if (NotifyHeaderTip()) { + LOCK(cs_main); + if (IsInitialBlockDownload() && ppindex && *ppindex) { + LogPrintf("sync headers, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight); + } + } return true; }