diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1988,9 +1988,7 @@ } CValidationState state; - CBlockHeader first_invalid_header; - if (!ProcessNewBlockHeaders(config, headers, state, &pindexLast, - &first_invalid_header)) { + if (!ProcessNewBlockHeaders(config, headers, state, &pindexLast)) { if (state.IsInvalid()) { MaybePunishNode(pfrom->GetId(), state, via_compact_block, "invalid header received"); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -804,8 +804,7 @@ } CValidationState state; - ProcessNewBlockHeaders(config, {h}, state, /* ppindex */ nullptr, - /* first_invalid */ nullptr); + ProcessNewBlockHeaders(config, {h}, state); if (state.IsValid()) { return NullUniValue; } diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -96,8 +96,7 @@ CBlockHeader header = block->GetBlockHeader(); CValidationState state; - if (!ProcessNewBlockHeaders(GetConfig(), {header}, state, &pindex, - nullptr)) { + if (!ProcessNewBlockHeaders(GetConfig(), {header}, state, &pindex)) { return false; } } diff --git a/src/test/checkpoints_tests.cpp b/src/test/checkpoints_tests.cpp --- a/src/test/checkpoints_tests.cpp +++ b/src/test/checkpoints_tests.cpp @@ -81,8 +81,6 @@ */ BOOST_AUTO_TEST_CASE(ban_fork_prior_to_and_at_checkpoints) { MainnetConfigWithTestCheckpoints config; - - CBlockHeader invalid; const CBlockIndex *pindex = nullptr; // Start with mainnet genesis block @@ -93,8 +91,7 @@ { CValidationState state; - BOOST_CHECK(ProcessNewBlockHeaders(config, {headerG}, state, &pindex, - &invalid)); + BOOST_CHECK(ProcessNewBlockHeaders(config, {headerG}, state, &pindex)); pindex = nullptr; } @@ -158,34 +155,28 @@ // Headers A and AA should be accepted { CValidationState state; - BOOST_CHECK(ProcessNewBlockHeaders(config, {headerA}, state, &pindex, - &invalid)); + BOOST_CHECK(ProcessNewBlockHeaders(config, {headerA}, state, &pindex)); BOOST_CHECK(state.IsValid()); BOOST_CHECK(pindex != nullptr); pindex = nullptr; - BOOST_CHECK(invalid.IsNull()); } { CValidationState state; - BOOST_CHECK(ProcessNewBlockHeaders(config, {headerAA}, state, &pindex, - &invalid)); + BOOST_CHECK(ProcessNewBlockHeaders(config, {headerAA}, state, &pindex)); BOOST_CHECK(state.IsValid()); BOOST_CHECK(pindex != nullptr); pindex = nullptr; - BOOST_CHECK(invalid.IsNull()); } // Header B should be rejected { CValidationState state; - BOOST_CHECK(!ProcessNewBlockHeaders(config, {headerB}, state, &pindex, - &invalid)); + BOOST_CHECK(!ProcessNewBlockHeaders(config, {headerB}, state, &pindex)); BOOST_CHECK(state.IsInvalid()); BOOST_CHECK(state.GetRejectCode() == REJECT_CHECKPOINT); BOOST_CHECK(state.GetRejectReason() == "bad-fork-prior-to-checkpoint"); BOOST_CHECK(pindex == nullptr); - BOOST_CHECK(invalid.GetHash() == headerB.GetHash()); } // Sanity check to ensure header was not saved in memory @@ -197,13 +188,12 @@ // Header AB should be rejected { CValidationState state; - BOOST_CHECK(!ProcessNewBlockHeaders(config, {headerAB}, state, &pindex, - &invalid)); + BOOST_CHECK( + !ProcessNewBlockHeaders(config, {headerAB}, state, &pindex)); BOOST_CHECK(state.IsInvalid()); BOOST_CHECK(state.GetRejectCode() == REJECT_CHECKPOINT); BOOST_CHECK(state.GetRejectReason() == "checkpoint mismatch"); BOOST_CHECK(pindex == nullptr); - BOOST_CHECK(invalid.GetHash() == headerAB.GetHash()); } // Sanity check to ensure header was not saved in memory diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -311,14 +311,12 @@ * occurred processing them. * @param[out] ppindex If set, the pointer will be set to point to the * last new block index object for the given headers. - * @param[out] first_invalid First header that fails validation, if one exists. * @return True if block headers were accepted as valid. */ bool ProcessNewBlockHeaders(const Config &config, const std::vector &block, CValidationState &state, - const CBlockIndex **ppindex = nullptr, - CBlockHeader *first_invalid = nullptr) + const CBlockIndex **ppindex = nullptr) LOCKS_EXCLUDED(cs_main); /** diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3861,12 +3861,7 @@ bool ProcessNewBlockHeaders(const Config &config, const std::vector &headers, CValidationState &state, - const CBlockIndex **ppindex, - CBlockHeader *first_invalid) { - if (first_invalid != nullptr) { - first_invalid->SetNull(); - } - + const CBlockIndex **ppindex) { { LOCK(cs_main); for (const CBlockHeader &header : headers) { @@ -3874,9 +3869,6 @@ CBlockIndex *pindex = nullptr; if (!::ChainstateActive().AcceptBlockHeader(config, header, state, &pindex)) { - if (first_invalid) { - *first_invalid = header; - } return false; }