Skip to content

Commit 7267843

Browse files
committed
Globals: Make AcceptBlockHeader static (Fix #6163)
..and at the same time prevent AcceptBlockHeader() from calling global function Params()
1 parent 77beab7 commit 7267843

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,9 +2781,8 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
27812781
return true;
27822782
}
27832783

2784-
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex)
2784+
static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex=NULL)
27852785
{
2786-
const CChainParams& chainparams = Params();
27872786
AssertLockHeld(cs_main);
27882787
// Check for duplicate
27892788
uint256 hash = block.GetHash();
@@ -2836,7 +2835,7 @@ bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppi
28362835

28372836
CBlockIndex *&pindex = *ppindex;
28382837

2839-
if (!AcceptBlockHeader(block, state, &pindex))
2838+
if (!AcceptBlockHeader(block, state, chainparams, &pindex))
28402839
return false;
28412840

28422841
// Try to process all requested blocks that we don't have, but only
@@ -4498,7 +4497,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
44984497
Misbehaving(pfrom->GetId(), 20);
44994498
return error("non-continuous headers sequence");
45004499
}
4501-
if (!AcceptBlockHeader(header, state, &pindexLast)) {
4500+
if (!AcceptBlockHeader(header, state, chainparams, &pindexLast)) {
45024501
int nDoS;
45034502
if (state.IsInvalid(nDoS)) {
45044503
if (nDoS > 0)

src/main.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
380380

381381
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
382382
bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
383-
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex **ppindex= NULL);
384383

385384

386385
class CBlockFileInfo

0 commit comments

Comments
 (0)