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

Function ProcessNewBlockHeaders

src/validation.cpp:3659–3677  ·  view source on GitHub ↗

Exposed wrapper for AcceptBlockHeader

Source from the content-addressed store, hash-verified

3657
3658// Exposed wrapper for AcceptBlockHeader
3659bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, CValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex, CBlockHeader *first_invalid)
3660{
3661 if (first_invalid != nullptr) first_invalid->SetNull();
3662 {
3663 LOCK(cs_main);
3664 for (const CBlockHeader& header : headers) {
3665 CBlockIndex *pindex = nullptr; // Use a temp pindex instead of ppindex to avoid a const_cast
3666 if (!g_chainstate.AcceptBlockHeader(header, state, chainparams, &pindex)) {
3667 if (first_invalid) *first_invalid = header;
3668 return false;
3669 }
3670 if (ppindex) {
3671 *ppindex = pindex;
3672 }
3673 }
3674 }
3675 NotifyHeaderTip();
3676 return true;
3677}
3678
3679/** Store block on disk. If dbp is non-nullptr, the file is known to already reside on disk */
3680static CDiskBlockPos SaveBlockToDisk(const CBlock& block, int nHeight, const CChainParams& chainparams, const CDiskBlockPos* dbp) {

Callers 3

ProcessHeadersMessageFunction · 0.85
ProcessMessageFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 2

AcceptBlockHeaderMethod · 0.80
SetNullMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68