Skip to content

Commit c651df8

Browse files
committed
Lock cs_main while loading block index in AppInitMain
1 parent 02de6a6 commit c651df8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/init.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,8 @@ bool AppInitMain()
14241424

14251425
uiInterface.InitMessage(_("Loading block index..."));
14261426

1427+
LOCK(cs_main);
1428+
14271429
nStart = GetTimeMillis();
14281430
do {
14291431
try {
@@ -1532,16 +1534,13 @@ bool AppInitMain()
15321534
MIN_BLOCKS_TO_KEEP);
15331535
}
15341536

1535-
{
1536-
LOCK(cs_main);
1537-
CBlockIndex* tip = chainActive.Tip();
1538-
RPCNotifyBlockChange(true, tip);
1539-
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
1540-
strLoadError = _("The block database contains a block which appears to be from the future. "
1541-
"This may be due to your computer's date and time being set incorrectly. "
1542-
"Only rebuild the block database if you are sure that your computer's date and time are correct");
1543-
break;
1544-
}
1537+
CBlockIndex* tip = chainActive.Tip();
1538+
RPCNotifyBlockChange(true, tip);
1539+
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
1540+
strLoadError = _("The block database contains a block which appears to be from the future. "
1541+
"This may be due to your computer's date and time being set incorrectly. "
1542+
"Only rebuild the block database if you are sure that your computer's date and time are correct");
1543+
break;
15451544
}
15461545

15471546
if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview.get(), gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),

0 commit comments

Comments
 (0)