Skip to content

Commit 9ec75c5

Browse files
committed
Add a locking mechanism to IsInitialBlockDownload to ensure it never goes from false to true.
1 parent a2d0fc6 commit 9ec75c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,14 @@ bool IsInitialBlockDownload()
11771177
LOCK(cs_main);
11781178
if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
11791179
return true;
1180-
return (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
1180+
static bool lockIBDState = false;
1181+
if (lockIBDState)
1182+
return false;
1183+
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
11811184
pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60);
1185+
if (!state)
1186+
lockIBDState = true;
1187+
return state;
11821188
}
11831189

11841190
bool fLargeWorkForkFound = false;

0 commit comments

Comments
 (0)