Add -forceibdcomplete and use IBD to allow all-peer headers-sync.

This uses IsInitialBlockDownload to enable headers-fetching from
all peers (in addition to the existing recent-headers-tip check).
It also adds a hidden flag which allows you to force IBD to false,
enabling download from all peers.
This commit is contained in:
Matt Corallo 2015-04-16 14:30:41 -07:00
parent f40b9feb2e
commit 253f634396

View file

@ -1344,6 +1344,8 @@ CAmount GetBlockValue(int nHeight, const CAmount& nFees)
bool IsInitialBlockDownload()
{
if (GetBoolArg("-forceibdcomplete", false))
return false;
LOCK(cs_main);
if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
return true;
@ -4715,7 +4717,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
// Only actively request headers from a single peer, unless we're close to today.
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60 || !IsInitialBlockDownload()) {
state.fSyncStarted = true;
nSyncStarted++;
CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader;