Exposed wrapper for AcceptBlockHeader
| 3657 | |
| 3658 | // Exposed wrapper for AcceptBlockHeader |
| 3659 | bool 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 */ |
| 3680 | static CDiskBlockPos SaveBlockToDisk(const CBlock& block, int nHeight, const CChainParams& chainparams, const CDiskBlockPos* dbp) { |