Merge pull request #5158
9ec75c5
Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true. (Ruben Dario Ponticelli)a2d0fc6
Fix IsInitialBlockDownload which was broken by headers first. (Ruben Dario Ponticelli)
This commit is contained in:
commit
9ff0bc9beb
1 changed files with 8 additions and 9 deletions
17
src/main.cpp
17
src/main.cpp
|
@ -1199,15 +1199,14 @@ bool IsInitialBlockDownload()
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
|
if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
|
||||||
return true;
|
return true;
|
||||||
static int64_t nLastUpdate;
|
static bool lockIBDState = false;
|
||||||
static CBlockIndex* pindexLastBest;
|
if (lockIBDState)
|
||||||
if (chainActive.Tip() != pindexLastBest)
|
return false;
|
||||||
{
|
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
|
||||||
pindexLastBest = chainActive.Tip();
|
pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60);
|
||||||
nLastUpdate = GetTime();
|
if (!state)
|
||||||
}
|
lockIBDState = true;
|
||||||
return (GetTime() - nLastUpdate < 10 &&
|
return state;
|
||||||
chainActive.Tip()->GetBlockTime() < GetTime() - 24 * 60 * 60);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fLargeWorkForkFound = false;
|
bool fLargeWorkForkFound = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue