From 253f634396d03e32e4b7dfd2a67de5e2b41ea1cb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 16 Apr 2015 14:30:41 -0700 Subject: [PATCH] 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. --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d66a5f4ac2..04c0ecf79b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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;