# HG changeset patch # User s_nakamoto # Date 1280259784 0 # Node ID 3f00395754792740177689e867c43de476554177 # Parent f7fb9a523442a6406ce019239ef6e044d08c3442 better IsInitialBlockDownload git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@115 1a98c847-1fd6-4fd8-948a-caf3550aa51b diff --git a/main.cpp b/main.cpp --- a/main.cpp +++ b/main.cpp @@ -850,22 +850,19 @@ return bnNew.GetCompact(); } -vector vStartingHeight; -void AddStartingHeight(int nStartingHeight) -{ - if (nStartingHeight != -1) - { - vStartingHeight.push_back(nStartingHeight); - sort(vStartingHeight.begin(), vStartingHeight.end()); - } -} - bool IsInitialBlockDownload() { - int nMedian = 69000; - if (vStartingHeight.size() >= 5) - nMedian = vStartingHeight[vStartingHeight.size()/2]; - return nBestHeight < nMedian-1000; + if (pindexBest == NULL) + return true; + static int64 nLastUpdate; + static CBlockIndex* pindexLastBest; + if (pindexBest != pindexLastBest) + { + pindexLastBest = pindexBest; + nLastUpdate = GetTime(); + } + return (GetTime() - nLastUpdate < 10 && + pindexBest->nTime < GetTime() - 24 * 60 * 60); } @@ -1923,7 +1920,6 @@ } AddTimeData(pfrom->addr.ip, nTime); - AddStartingHeight(pfrom->nStartingHeight); // Change version if (pfrom->nVersion >= 209)