mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-25 22:34:27 +00:00
better IsInitialBlockDownload
This commit is contained in:
parent
3dd20ff2f8
commit
2689f4d02b
26
main.cpp
26
main.cpp
@ -850,22 +850,19 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast)
|
|||||||
return bnNew.GetCompact();
|
return bnNew.GetCompact();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<int> vStartingHeight;
|
|
||||||
void AddStartingHeight(int nStartingHeight)
|
|
||||||
{
|
|
||||||
if (nStartingHeight != -1)
|
|
||||||
{
|
|
||||||
vStartingHeight.push_back(nStartingHeight);
|
|
||||||
sort(vStartingHeight.begin(), vStartingHeight.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsInitialBlockDownload()
|
bool IsInitialBlockDownload()
|
||||||
{
|
{
|
||||||
int nMedian = 69000;
|
if (pindexBest == NULL)
|
||||||
if (vStartingHeight.size() >= 5)
|
return true;
|
||||||
nMedian = vStartingHeight[vStartingHeight.size()/2];
|
static int64 nLastUpdate;
|
||||||
return nBestHeight < nMedian-1000;
|
static CBlockIndex* pindexLastBest;
|
||||||
|
if (pindexBest != pindexLastBest)
|
||||||
|
{
|
||||||
|
pindexLastBest = pindexBest;
|
||||||
|
nLastUpdate = GetTime();
|
||||||
|
}
|
||||||
|
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);
|
AddTimeData(pfrom->addr.ip, nTime);
|
||||||
AddStartingHeight(pfrom->nStartingHeight);
|
|
||||||
|
|
||||||
// Change version
|
// Change version
|
||||||
if (pfrom->nVersion >= 209)
|
if (pfrom->nVersion >= 209)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user