IBD check uses minimumchain work instead of checkpoints.

This commit is contained in:
Gregory Maxwell
2016-10-22 05:33:25 +00:00
committed by lateminer
parent 75402d67c1
commit 1bf644c43f
3 changed files with 15 additions and 2 deletions

View File

@@ -119,6 +119,9 @@ public:
consensus.nStakeMinConfirmations = 500;
consensus.nStakeMinAge = 8 * 60 * 60; // 8 hours
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
/**
* The message start string is designed to be unlikely to occur in normal data.
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
@@ -215,6 +218,10 @@ public:
pchMessageStart[3] = 0xef;
nDefaultPort = 25714;
nMaxTipAge = 0x7fffffff;
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
nPruneAfterHeight = 1000;
genesis = CreateGenesisBlock(1393221600, 216178, 0x1f00ffff, 1, 0);
@@ -280,6 +287,9 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
// Deployment of BIP68, BIP112, and BIP113.
// consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
// consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 999999999999ULL; // never

View File

@@ -75,6 +75,7 @@ struct Params {
int nCoinbaseMaturity;
int nStakeMinConfirmations;
unsigned int nStakeMinAge;
uint256 nMinimumChainWork;
};
} // namespace Consensus

View File

@@ -1698,7 +1698,9 @@ bool IsInitialBlockDownload()
LOCK(cs_main);
if (fImporting || fReindex)
return true;
if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()))
if (chainActive.Tip() == NULL)
return true;
if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork))
return true;
static bool lockIBDState = false;
if (lockIBDState)
@@ -1738,7 +1740,7 @@ void CheckForkWarningConditions()
{
AssertLockHeld(cs_main);
// Before we get past initial download, we cannot reliably alert about forks
// (we assume we don't get stuck on a fork before the last checkpoint)
// (we assume we don't get stuck on a fork before finishing our initial sync)
if (IsInitialBlockDownload())
return;