diff options
author | --author=Satoshi Nakamoto <satoshin@gmx.com> | 2010-07-27 20:46:41 +0000 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2010-07-27 20:46:41 +0000 |
commit | 2689f4d02b0632926c815e58363e8e7292586242 (patch) | |
tree | cc27fb6e342bfd72f382edd7e1fe71d4ac5364a4 | |
parent | 3dd20ff2f87958a440c9dceae8abe3967aa48fcf (diff) |
better IsInitialBlockDownload
-rw-r--r-- | main.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -850,22 +850,19 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast) return bnNew.GetCompact(); } -vector<int> vStartingHeight; -void AddStartingHeight(int nStartingHeight) +bool IsInitialBlockDownload() { - if (nStartingHeight != -1) + if (pindexBest == NULL) + return true; + static int64 nLastUpdate; + static CBlockIndex* pindexLastBest; + if (pindexBest != pindexLastBest) { - vStartingHeight.push_back(nStartingHeight); - sort(vStartingHeight.begin(), vStartingHeight.end()); + pindexLastBest = pindexBest; + nLastUpdate = GetTime(); } -} - -bool IsInitialBlockDownload() -{ - int nMedian = 69000; - if (vStartingHeight.size() >= 5) - nMedian = vStartingHeight[vStartingHeight.size()/2]; - return nBestHeight < nMedian-1000; + return (GetTime() - nLastUpdate < 10 && + pindexBest->nTime < GetTime() - 24 * 60 * 60); } @@ -1923,7 +1920,6 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } AddTimeData(pfrom->addr.ip, nTime); - AddStartingHeight(pfrom->nStartingHeight); // Change version if (pfrom->nVersion >= 209) |