@@ -1204,8 +1204,9 @@ CAmount GetBlockValue(int nHeight, const CAmount& nFees)
1204
1204
1205
1205
bool IsInitialBlockDownload ()
1206
1206
{
1207
+ const CChainParams& chainParams = Params ();
1207
1208
LOCK (cs_main);
1208
- if (fImporting || fReindex || chainActive.Height () < Checkpoints::GetTotalBlocksEstimate ())
1209
+ if (fImporting || fReindex || chainActive.Height () < Checkpoints::GetTotalBlocksEstimate (chainParams. Checkpoints () ))
1209
1210
return true ;
1210
1211
static bool lockIBDState = false ;
1211
1212
if (lockIBDState)
@@ -1709,7 +1710,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1709
1710
return true ;
1710
1711
}
1711
1712
1712
- bool fScriptChecks = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate ();
1713
+ bool fScriptChecks = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate (chainparams. Checkpoints () );
1713
1714
1714
1715
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
1715
1716
// unless those are already completely spent.
@@ -1954,6 +1955,7 @@ void PruneAndFlush() {
1954
1955
1955
1956
/* * Update chainActive and related internal data structures. */
1956
1957
void static UpdateTip (CBlockIndex *pindexNew) {
1958
+ const CChainParams& chainParams = Params ();
1957
1959
chainActive.SetTip (pindexNew);
1958
1960
1959
1961
// New best block
@@ -1963,7 +1965,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
1963
1965
LogPrintf (" %s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%u\n " , __func__,
1964
1966
chainActive.Tip ()->GetBlockHash ().ToString (), chainActive.Height (), log (chainActive.Tip ()->nChainWork .getdouble ())/log (2.0 ), (unsigned long )chainActive.Tip ()->nChainTx ,
1965
1967
DateTimeStrFormat (" %Y-%m-%d %H:%M:%S" , chainActive.Tip ()->GetBlockTime ()),
1966
- Checkpoints::GuessVerificationProgress (chainActive.Tip ()), (unsigned int )pcoinsTip->GetCacheSize ());
1968
+ Checkpoints::GuessVerificationProgress (chainParams. Checkpoints (), chainActive.Tip ()), (unsigned int )pcoinsTip->GetCacheSize ());
1967
1969
1968
1970
cvBlockChange.notify_all ();
1969
1971
@@ -2247,6 +2249,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
2247
2249
bool ActivateBestChain (CValidationState &state, CBlock *pblock) {
2248
2250
CBlockIndex *pindexNewTip = NULL ;
2249
2251
CBlockIndex *pindexMostWork = NULL ;
2252
+ const CChainParams& chainParams = Params ();
2250
2253
do {
2251
2254
boost::this_thread::interruption_point ();
2252
2255
@@ -2271,7 +2274,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
2271
2274
if (!fInitialDownload ) {
2272
2275
uint256 hashNewTip = pindexNewTip->GetBlockHash ();
2273
2276
// Relay inventory, but don't relay old inventory during initial block download.
2274
- int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate ();
2277
+ int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate (chainParams. Checkpoints () );
2275
2278
// Don't relay blocks if pruning -- could cause a peer to try to download, resulting
2276
2279
// in a stalled download if the block file is pruned before the request.
2277
2280
if (nLocalServices & NODE_NETWORK) {
@@ -2601,7 +2604,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2601
2604
2602
2605
bool ContextualCheckBlockHeader (const CBlockHeader& block, CValidationState& state, CBlockIndex * const pindexPrev)
2603
2606
{
2604
- const Consensus::Params& consensusParams = Params ().GetConsensus ();
2607
+ const CChainParams& chainParams = Params ();
2608
+ const Consensus::Params& consensusParams = chainParams.GetConsensus ();
2605
2609
uint256 hash = block.GetHash ();
2606
2610
if (hash == consensusParams.hashGenesisBlock )
2607
2611
return true ;
@@ -2611,7 +2615,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
2611
2615
int nHeight = pindexPrev->nHeight +1 ;
2612
2616
2613
2617
// Check proof of work
2614
- if (block.nBits != GetNextWorkRequired (pindexPrev, &block, Params (). GetConsensus () ))
2618
+ if (block.nBits != GetNextWorkRequired (pindexPrev, &block, consensusParams ))
2615
2619
return state.DoS (100 , error (" %s: incorrect proof of work" , __func__),
2616
2620
REJECT_INVALID, " bad-diffbits" );
2617
2621
@@ -2621,24 +2625,24 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
2621
2625
REJECT_INVALID, " time-too-old" );
2622
2626
2623
2627
// Check that the block chain matches the known block chain up to a checkpoint
2624
- if (!Checkpoints::CheckBlock (nHeight, hash))
2628
+ if (!Checkpoints::CheckBlock (chainParams. Checkpoints (), nHeight, hash))
2625
2629
return state.DoS (100 , error (" %s: rejected by checkpoint lock-in at %d" , __func__, nHeight),
2626
2630
REJECT_CHECKPOINT, " checkpoint mismatch" );
2627
2631
2628
2632
// Don't accept any forks from the main chain prior to last checkpoint
2629
- CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint ();
2633
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint (chainParams. Checkpoints () );
2630
2634
if (pcheckpoint && nHeight < pcheckpoint->nHeight )
2631
2635
return state.DoS (100 , error (" %s: forked chain older than last checkpoint (height %d)" , __func__, nHeight));
2632
2636
2633
2637
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
2634
- if (block.nVersion < 2 && IsSuperMajority (2 , pindexPrev, Params (). RejectBlockOutdatedMajority () ))
2638
+ if (block.nVersion < 2 && IsSuperMajority (2 , pindexPrev, consensusParams. nMajorityRejectBlockOutdated ))
2635
2639
{
2636
2640
return state.Invalid (error (" %s: rejected nVersion=1 block" , __func__),
2637
2641
REJECT_OBSOLETE, " bad-version" );
2638
2642
}
2639
2643
2640
2644
// Reject block.nVersion=2 blocks when 95% (75% on testnet) of the network has upgraded:
2641
- if (block.nVersion < 3 && IsSuperMajority (3 , pindexPrev, Params (). RejectBlockOutdatedMajority () ))
2645
+ if (block.nVersion < 3 && IsSuperMajority (3 , pindexPrev, consensusParams. nMajorityRejectBlockOutdated ))
2642
2646
{
2643
2647
return state.Invalid (error (" %s : rejected nVersion=2 block" , __func__),
2644
2648
REJECT_OBSOLETE, " bad-version" );
@@ -3025,6 +3029,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
3025
3029
3026
3030
bool static LoadBlockIndexDB ()
3027
3031
{
3032
+ const CChainParams& chainparams = Params ();
3028
3033
if (!pblocktree->LoadBlockIndexGuts ())
3029
3034
return false ;
3030
3035
@@ -3127,7 +3132,7 @@ bool static LoadBlockIndexDB()
3127
3132
LogPrintf (" %s: hashBestChain=%s height=%d date=%s progress=%f\n " , __func__,
3128
3133
chainActive.Tip ()->GetBlockHash ().ToString (), chainActive.Height (),
3129
3134
DateTimeStrFormat (" %Y-%m-%d %H:%M:%S" , chainActive.Tip ()->GetBlockTime ()),
3130
- Checkpoints::GuessVerificationProgress (chainActive.Tip ()));
3135
+ Checkpoints::GuessVerificationProgress (chainparams. Checkpoints (), chainActive.Tip ()));
3131
3136
3132
3137
return true ;
3133
3138
}
0 commit comments