MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ProcessNewBlockHeaders

Method ProcessNewBlockHeaders

src/validation.cpp:4252–4280  ·  view source on GitHub ↗

Exposed wrapper for AcceptBlockHeader

Source from the content-addressed store, hash-verified

4250
4251// Exposed wrapper for AcceptBlockHeader
4252bool ChainstateManager::ProcessNewBlockHeaders(std::span<const CBlockHeader> headers, bool min_pow_checked, BlockValidationState& state, const CBlockIndex** ppindex)
4253{
4254 AssertLockNotHeld(cs_main);
4255 {
4256 LOCK(cs_main);
4257 for (const CBlockHeader& header : headers) {
4258 CBlockIndex *pindex = nullptr; // Use a temp pindex instead of ppindex to avoid a const_cast
4259 bool accepted{AcceptBlockHeader(header, state, &pindex, min_pow_checked)};
4260 CheckBlockIndex();
4261
4262 if (!accepted) {
4263 return false;
4264 }
4265 if (ppindex) {
4266 *ppindex = pindex;
4267 }
4268 }
4269 }
4270 if (NotifyHeaderTip()) {
4271 if (IsInitialBlockDownload() && ppindex && *ppindex) {
4272 const CBlockIndex& last_accepted{**ppindex};
4273 int64_t blocks_left{(NodeClock::now() - last_accepted.Time()) / GetConsensus().PowTargetSpacing()};
4274 blocks_left = std::max<int64_t>(0, blocks_left);
4275 const double progress{100.0 * last_accepted.nHeight / (last_accepted.nHeight + blocks_left)};
4276 LogInfo("Synchronizing blockheaders, height: %d (~%.2f%%)\n", last_accepted.nHeight, progress);
4277 }
4278 }
4279 return true;
4280}
4281
4282void ChainstateManager::ReportHeadersPresync(int64_t height, int64_t timestamp)
4283{

Callers 8

ProcessHeadersMessageMethod · 0.80
ProcessMessageMethod · 0.80
BuildChainMethod · 0.80
FinalizeBlockMethod · 0.80
initialize_chainFunction · 0.80
utxo_snapshot_fuzzFunction · 0.80
submitheaderFunction · 0.80

Calls 3

CheckBlockIndexFunction · 0.85
PowTargetSpacingMethod · 0.80
TimeMethod · 0.45

Tested by 4

BuildChainMethod · 0.64
FinalizeBlockMethod · 0.64
initialize_chainFunction · 0.64
utxo_snapshot_fuzzFunction · 0.64