aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author--author=Satoshi Nakamoto <satoshin@gmx.com>2010-07-27 20:46:41 +0000
committerGavin Andresen <gavinandresen@gmail.com>2010-07-27 20:46:41 +0000
commit2689f4d02b0632926c815e58363e8e7292586242 (patch)
treecc27fb6e342bfd72f382edd7e1fe71d4ac5364a4
parent3dd20ff2f87958a440c9dceae8abe3967aa48fcf (diff)
better IsInitialBlockDownload
-rw-r--r--main.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/main.cpp b/main.cpp
index 15a182dde8..296765300b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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)