Skip to content

Commit c428622

Browse files
committed
[validation] Remove unused first_invalid parameter from ProcessNewBlockHeaders()
No callers use the returned value in first_invalid. Remove it from the function signature and don't set it in the function.
1 parent 7204c64 commit c428622

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,8 +1698,7 @@ bool static ProcessHeadersMessage(CNode *pfrom, CConnman *connman, const std::ve
16981698
}
16991699

17001700
BlockValidationState state;
1701-
CBlockHeader first_invalid_header;
1702-
if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast, &first_invalid_header)) {
1701+
if (!ProcessNewBlockHeaders(headers, state, chainparams, &pindexLast)) {
17031702
if (state.IsInvalid()) {
17041703
MaybePunishNodeForBlock(pfrom->GetId(), state, via_compact_block, "invalid header received");
17051704
return false;

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ static UniValue submitheader(const JSONRPCRequest& request)
773773
}
774774

775775
BlockValidationState state;
776-
ProcessNewBlockHeaders({h}, state, Params(), /* ppindex */ nullptr, /* first_invalid */ nullptr);
776+
ProcessNewBlockHeaders({h}, state, Params());
777777
if (state.IsValid()) return NullUniValue;
778778
if (state.IsError()) {
779779
throw JSONRPCError(RPC_VERIFY_ERROR, FormatStateMessage(state));

src/test/blockfilter_index_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static bool BuildChain(const CBlockIndex* pindex, const CScript& coinbase_script
103103
CBlockHeader header = block->GetBlockHeader();
104104

105105
BlockValidationState state;
106-
if (!ProcessNewBlockHeaders({header}, state, Params(), &pindex, nullptr)) {
106+
if (!ProcessNewBlockHeaders({header}, state, Params(), &pindex)) {
107107
return false;
108108
}
109109
}

src/validation.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,9 +3619,8 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
36193619
}
36203620

36213621
// Exposed wrapper for AcceptBlockHeader
3622-
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex, CBlockHeader *first_invalid)
3622+
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex)
36233623
{
3624-
if (first_invalid != nullptr) first_invalid->SetNull();
36253624
{
36263625
LOCK(cs_main);
36273626
for (const CBlockHeader& header : headers) {
@@ -3630,7 +3629,6 @@ bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& headers, BlockValid
36303629
::ChainstateActive().CheckBlockIndex(chainparams.GetConsensus());
36313630

36323631
if (!accepted) {
3633-
if (first_invalid) *first_invalid = header;
36343632
return false;
36353633
}
36363634
if (ppindex) {

src/validation.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
222222
* @param[out] state This may be set to an Error state if any error occurred processing them
223223
* @param[in] chainparams The params for the chain we want to connect to
224224
* @param[out] ppindex If set, the pointer will be set to point to the last new block index object for the given headers
225-
* @param[out] first_invalid First header that fails validation, if one exists
226225
*/
227-
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex = nullptr, CBlockHeader* first_invalid = nullptr) LOCKS_EXCLUDED(cs_main);
226+
bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, BlockValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex = nullptr) LOCKS_EXCLUDED(cs_main);
228227

229228
/** Open a block file (blk?????.dat) */
230229
FILE* OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false);

0 commit comments

Comments
 (0)