Skip to content

Commit dfe1341

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#24033: log: Remove GetAdjustedTime from IBD header progress estimation
fac22fd log: Remove GetAdjustedTime from IBD header progress estimation (MarcoFalke) Pull request description: This is a "refactor" that shouldn't change behaviour, because the two times are most likely equal. A minimum of 5 outbound peers are needed to adjust the time. And if the time is adjusted, it will be by at most 70 minutes (`DEFAULT_MAX_TIME_ADJUSTMENT`). Thus, the progress estimate should differ by at most 7 blocks. ACKs for top commit: laanwj: Code review ACK fac22fd vincenzopalazzo: ACK bitcoin/bitcoin@fac22fd Tree-SHA512: bf9f5eef66db0110dd268cf6dbfab64b9c11ba776924f5b386ceae3f2d005272cceb87ebcc96e0c8b854c051514854a2a5af39ae43bad008fac685b5aafaabd0
2 parents 7de2cf9 + fac22fd commit dfe1341

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/validation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3528,7 +3528,10 @@ bool ChainstateManager::ProcessNewBlockHeaders(const std::vector<CBlockHeader>&
35283528
}
35293529
if (NotifyHeaderTip(ActiveChainstate())) {
35303530
if (ActiveChainstate().IsInitialBlockDownload() && ppindex && *ppindex) {
3531-
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", (*ppindex)->nHeight, 100.0/((*ppindex)->nHeight+(GetAdjustedTime() - (*ppindex)->GetBlockTime()) / Params().GetConsensus().nPowTargetSpacing) * (*ppindex)->nHeight);
3531+
const CBlockIndex& last_accepted{**ppindex};
3532+
const int64_t blocks_left{(GetTime() - last_accepted.GetBlockTime()) / chainparams.GetConsensus().nPowTargetSpacing};
3533+
const double progress{100.0 * last_accepted.nHeight / (last_accepted.nHeight + blocks_left)};
3534+
LogPrintf("Synchronizing blockheaders, height: %d (~%.2f%%)\n", last_accepted.nHeight, progress);
35323535
}
35333536
}
35343537
return true;

0 commit comments

Comments
 (0)