@@ -56,6 +56,7 @@ bool fHavePruned = false;
56
56
bool fPruneMode = false ;
57
57
bool fIsBareMultisigStd = true ;
58
58
bool fCheckBlockIndex = false ;
59
+ bool fCheckpointsEnabled = true ;
59
60
unsigned int nCoinCacheSize = 5000 ;
60
61
uint64_t nPruneTarget = 0 ;
61
62
@@ -1206,7 +1207,9 @@ bool IsInitialBlockDownload()
1206
1207
{
1207
1208
const CChainParams& chainParams = Params ();
1208
1209
LOCK (cs_main);
1209
- if (fImporting || fReindex || chainActive.Height () < Checkpoints::GetTotalBlocksEstimate (chainParams.Checkpoints ()))
1210
+ if (fImporting || fReindex )
1211
+ return true ;
1212
+ if (fCheckpointsEnabled && chainActive.Height () < Checkpoints::GetTotalBlocksEstimate (chainParams.Checkpoints ()))
1210
1213
return true ;
1211
1214
static bool lockIBDState = false ;
1212
1215
if (lockIBDState)
@@ -1710,7 +1713,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1710
1713
return true ;
1711
1714
}
1712
1715
1713
- bool fScriptChecks = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate (chainparams.Checkpoints ());
1716
+ bool fScriptChecks = (! fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate (chainparams.Checkpoints () ));
1714
1717
1715
1718
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
1716
1719
// unless those are already completely spent.
@@ -2274,7 +2277,9 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
2274
2277
if (!fInitialDownload ) {
2275
2278
uint256 hashNewTip = pindexNewTip->GetBlockHash ();
2276
2279
// Relay inventory, but don't relay old inventory during initial block download.
2277
- int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate (chainParams.Checkpoints ());
2280
+ int nBlockEstimate = 0 ;
2281
+ if (fCheckpointsEnabled )
2282
+ nBlockEstimate = Checkpoints::GetTotalBlocksEstimate (chainParams.Checkpoints ());
2278
2283
// Don't relay blocks if pruning -- could cause a peer to try to download, resulting
2279
2284
// in a stalled download if the block file is pruned before the request.
2280
2285
if (nLocalServices & NODE_NETWORK) {
@@ -2624,15 +2629,18 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
2624
2629
return state.Invalid (error (" %s: block's timestamp is too early" , __func__),
2625
2630
REJECT_INVALID, " time-too-old" );
2626
2631
2627
- // Check that the block chain matches the known block chain up to a checkpoint
2628
- if (!Checkpoints::CheckBlock (chainParams.Checkpoints (), nHeight, hash))
2629
- return state.DoS (100 , error (" %s: rejected by checkpoint lock-in at %d" , __func__, nHeight),
2630
- REJECT_CHECKPOINT, " checkpoint mismatch" );
2632
+ if (fCheckpointsEnabled )
2633
+ {
2634
+ // Check that the block chain matches the known block chain up to a checkpoint
2635
+ if (!Checkpoints::CheckBlock (chainParams.Checkpoints (), nHeight, hash))
2636
+ return state.DoS (100 , error (" %s: rejected by checkpoint lock-in at %d" , __func__, nHeight),
2637
+ REJECT_CHECKPOINT, " checkpoint mismatch" );
2631
2638
2632
- // Don't accept any forks from the main chain prior to last checkpoint
2633
- CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint (chainParams.Checkpoints ());
2634
- if (pcheckpoint && nHeight < pcheckpoint->nHeight )
2635
- return state.DoS (100 , error (" %s: forked chain older than last checkpoint (height %d)" , __func__, nHeight));
2639
+ // Don't accept any forks from the main chain prior to last checkpoint
2640
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint (chainParams.Checkpoints ());
2641
+ if (pcheckpoint && nHeight < pcheckpoint->nHeight )
2642
+ return state.DoS (100 , error (" %s: forked chain older than last checkpoint (height %d)" , __func__, nHeight));
2643
+ }
2636
2644
2637
2645
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
2638
2646
if (block.nVersion < 2 && IsSuperMajority (2 , pindexPrev, consensusParams.nMajorityRejectBlockOutdated ))
0 commit comments