@@ -1680,6 +1680,7 @@ static int64_t nTimeTotal = 0;
1680
1680
1681
1681
bool ConnectBlock (const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck )
1682
1682
{
1683
+ const CChainParams& chainparams = Params ();
1683
1684
AssertLockHeld (cs_main);
1684
1685
// Check it again in case a previous version let a bad block in
1685
1686
if (!CheckBlock (block, state, !fJustCheck , !fJustCheck ))
@@ -1691,7 +1692,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1691
1692
1692
1693
// Special case for the genesis block, skipping connection of its transactions
1693
1694
// (its coinbase is unspendable)
1694
- if (block.GetHash () == Params (). HashGenesisBlock () ) {
1695
+ if (block.GetHash () == chainparams. GetConsensus (). hashGenesisBlock ) {
1695
1696
if (!fJustCheck )
1696
1697
view.SetBestBlock (pindex->GetBlockHash ());
1697
1698
return true ;
@@ -2541,8 +2542,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2541
2542
2542
2543
bool ContextualCheckBlockHeader (const CBlockHeader& block, CValidationState& state, CBlockIndex * const pindexPrev)
2543
2544
{
2545
+ const Consensus::Params& consensusParams = Params ().GetConsensus ();
2544
2546
uint256 hash = block.GetHash ();
2545
- if (hash == Params (). HashGenesisBlock () )
2547
+ if (hash == consensusParams. hashGenesisBlock )
2546
2548
return true ;
2547
2549
2548
2550
assert (pindexPrev);
@@ -2612,6 +2614,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
2612
2614
2613
2615
bool AcceptBlockHeader (const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex)
2614
2616
{
2617
+ const CChainParams& chainparams = Params ();
2615
2618
AssertLockHeld (cs_main);
2616
2619
// Check for duplicate
2617
2620
uint256 hash = block.GetHash ();
@@ -2632,7 +2635,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
2632
2635
2633
2636
// Get prev block index
2634
2637
CBlockIndex* pindexPrev = NULL ;
2635
- if (hash != Params (). HashGenesisBlock () ) {
2638
+ if (hash != chainparams. GetConsensus (). hashGenesisBlock ) {
2636
2639
BlockMap::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
2637
2640
if (mi == mapBlockIndex.end ())
2638
2641
return state.DoS (10 , error (" %s: prev block not found" , __func__), 0 , " bad-prevblk" );
@@ -3119,6 +3122,7 @@ bool InitBlockIndex() {
3119
3122
3120
3123
bool LoadExternalBlockFile (FILE* fileIn, CDiskBlockPos *dbp)
3121
3124
{
3125
+ const CChainParams& chainparams = Params ();
3122
3126
// Map of disk positions for blocks with unknown parent (only used for reindex)
3123
3127
static std::multimap<uint256, CDiskBlockPos> mapBlocksUnknownParent;
3124
3128
int64_t nStart = GetTimeMillis ();
@@ -3164,7 +3168,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
3164
3168
3165
3169
// detect out of order blocks, and store them for later
3166
3170
uint256 hash = block.GetHash ();
3167
- if (hash != Params (). HashGenesisBlock () && mapBlockIndex.find (block.hashPrevBlock ) == mapBlockIndex.end ()) {
3171
+ if (hash != chainparams. GetConsensus (). hashGenesisBlock && mapBlockIndex.find (block.hashPrevBlock ) == mapBlockIndex.end ()) {
3168
3172
LogPrint (" reindex" , " %s: Out of order block %s, parent %s not known\n " , __func__, hash.ToString (),
3169
3173
block.hashPrevBlock .ToString ());
3170
3174
if (dbp)
@@ -3179,7 +3183,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
3179
3183
nLoaded++;
3180
3184
if (state.IsError ())
3181
3185
break ;
3182
- } else if (hash != Params (). HashGenesisBlock () && mapBlockIndex[hash]->nHeight % 1000 == 0 ) {
3186
+ } else if (hash != chainparams. GetConsensus (). hashGenesisBlock && mapBlockIndex[hash]->nHeight % 1000 == 0 ) {
3183
3187
LogPrintf (" Block Import: already had block %s at height %d\n " , hash.ToString (), mapBlockIndex[hash]->nHeight );
3184
3188
}
3185
3189
@@ -3221,6 +3225,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
3221
3225
3222
3226
void static CheckBlockIndex ()
3223
3227
{
3228
+ const Consensus::Params& consensusParams = Params ().GetConsensus ();
3224
3229
if (!fCheckBlockIndex ) {
3225
3230
return ;
3226
3231
}
@@ -3263,7 +3268,7 @@ void static CheckBlockIndex()
3263
3268
// Begin: actual consistency checks.
3264
3269
if (pindex->pprev == NULL ) {
3265
3270
// Genesis block checks.
3266
- assert (pindex->GetBlockHash () == Params (). HashGenesisBlock () ); // Genesis block's hash must match.
3271
+ assert (pindex->GetBlockHash () == consensusParams. hashGenesisBlock ); // Genesis block's hash must match.
3267
3272
assert (pindex == chainActive.Genesis ()); // The current active chain's genesis block must be this block.
3268
3273
}
3269
3274
// HAVE_DATA is equivalent to VALID_TRANSACTIONS and equivalent to nTx > 0 (we stored the number of transactions in the block)
0 commit comments