aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-11-03 00:04:20 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2016-11-03 00:08:59 -0700
commit508404de98a8a5435f52916cef8f328e82651961 (patch)
treed7756cd64d414858f51d77f0273f26bc4e2e4e30 /src/main.cpp
parented0cc50afed146c27f6d8129c683c225fb940093 (diff)
parente141beb6a9816b7e1e680fb0a8bae16d42a3e557 (diff)
downloadbitcoin-508404de98a8a5435f52916cef8f328e82651961.tar.xz
Merge #9053: IBD using chainwork instead of height and not using header timestamps
e141beb IsInitialBlockDownload no longer uses header-only timestamps. (Gregory Maxwell) 2082b55 Remove GetTotalBlocksEstimate and checkpoint tests that test nothing. (Gregory Maxwell) fd46136 IBD check uses minimumchain work instead of checkpoints. (Gregory Maxwell)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4cc886afb5..44031e69e7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1746,13 +1746,14 @@ bool IsInitialBlockDownload()
return false;
if (fImporting || fReindex)
return true;
- if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(chainParams.Checkpoints()))
+ if (chainActive.Tip() == NULL)
return true;
- bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
- std::max(chainActive.Tip()->GetBlockTime(), pindexBestHeader->GetBlockTime()) < GetTime() - nMaxTipAge);
- if (!state)
- latchToFalse.store(true, std::memory_order_relaxed);
- return state;
+ if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork))
+ return true;
+ if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge))
+ return true;
+ latchToFalse.store(true, std::memory_order_relaxed);
+ return false;
}
bool fLargeWorkForkFound = false;
@@ -1780,7 +1781,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;