Mercurial > hg > bitcoin
changeset 186:b90b61469b5e draft
better IsInitialBlockDownload
author | --author=Satoshi Nakamoto <satoshin@gmx.com> |
---|---|
date | Tue, 27 Jul 2010 20:46:41 +0000 |
parents | f05e16cc0116 |
children | a3c4c2f26ed9 |
files | main.cpp |
diffstat | 1 files changed, 11 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/main.cpp +++ b/main.cpp @@ -850,22 +850,19 @@ return bnNew.GetCompact(); } -vector<int> 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)