Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,855 Lines • ▼ Show 20 Lines | bool CChainState::AcceptBlockHeader(const Config &config, | ||||
CheckBlockIndex(chainparams.GetConsensus()); | CheckBlockIndex(chainparams.GetConsensus()); | ||||
return true; | return true; | ||||
} | } | ||||
// Exposed wrapper for AcceptBlockHeader | // Exposed wrapper for AcceptBlockHeader | ||||
bool ProcessNewBlockHeaders(const Config &config, | bool ProcessNewBlockHeaders(const Config &config, | ||||
const std::vector<CBlockHeader> &headers, | const std::vector<CBlockHeader> &headers, | ||||
CValidationState &state, | CValidationState &state, | ||||
const CBlockIndex **ppindex, | const CBlockIndex **ppindex) { | ||||
CBlockHeader *first_invalid) { | |||||
if (first_invalid != nullptr) { | |||||
first_invalid->SetNull(); | |||||
} | |||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
for (const CBlockHeader &header : headers) { | for (const CBlockHeader &header : headers) { | ||||
// Use a temp pindex instead of ppindex to avoid a const_cast | // Use a temp pindex instead of ppindex to avoid a const_cast | ||||
CBlockIndex *pindex = nullptr; | CBlockIndex *pindex = nullptr; | ||||
if (!::ChainstateActive().AcceptBlockHeader(config, header, state, | if (!::ChainstateActive().AcceptBlockHeader(config, header, state, | ||||
&pindex)) { | &pindex)) { | ||||
if (first_invalid) { | |||||
*first_invalid = header; | |||||
} | |||||
return false; | return false; | ||||
} | } | ||||
if (ppindex) { | if (ppindex) { | ||||
*ppindex = pindex; | *ppindex = pindex; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,792 Lines • Show Last 20 Lines |