diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-11-26 14:58:02 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-11-26 15:09:03 +0100 |
| commit | 9ff0bc9beb90cf96fb0a9698de22e2bc60fed2f2 (patch) | |
| tree | 7ac7577461f132154e963f077373c17af7212e2b | |
| parent | Merge pull request #5273 (diff) | |
| parent | Add a locking mechanism to IsInitialBlockDownload to ensure it never goes fro... (diff) | |
| download | discoin-9ff0bc9beb90cf96fb0a9698de22e2bc60fed2f2.tar.xz discoin-9ff0bc9beb90cf96fb0a9698de22e2bc60fed2f2.zip | |
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)
| -rw-r--r-- | src/main.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main.cpp b/src/main.cpp index bda2ee7f7..0a81d0d7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1199,15 +1199,14 @@ bool IsInitialBlockDownload() LOCK(cs_main); if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate()) return true; - static int64_t nLastUpdate; - static CBlockIndex* pindexLastBest; - if (chainActive.Tip() != pindexLastBest) - { - pindexLastBest = chainActive.Tip(); - nLastUpdate = GetTime(); - } - return (GetTime() - nLastUpdate < 10 && - chainActive.Tip()->GetBlockTime() < GetTime() - 24 * 60 * 60); + static bool lockIBDState = false; + if (lockIBDState) + return false; + bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 || + pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60); + if (!state) + lockIBDState = true; + return state; } bool fLargeWorkForkFound = false; |