diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-07-27 19:43:04 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-07-27 19:43:04 +0000 |
commit | f79751c2997a72447f46927f200d78a6da50048d (patch) | |
tree | b8a08290bef10df157f90077c5b9b612afb44b68 | |
parent | 813505cc1313b7e191b787f93e573acb91fa1464 (diff) |
better IsInitialBlockDownload
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@115 1a98c847-1fd6-4fd8-948a-caf3550aa51b
-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)
|