Skip to content

Commit f261f19

Browse files
committed
Give a better error message if system clock is bad
Fixes #2007 This checks to see if the system clock appears to be bad and gives a helpful error message. If the user's clock is set incorrectly, hopefully they'll abort, fix it, and then save themselves a fruitless resync.
1 parent 1369d69 commit f261f19

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/init.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,18 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12251225
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
12261226
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
12271227
}
1228+
1229+
{
1230+
LOCK(cs_main);
1231+
CBlockIndex* tip = chainActive.Tip();
1232+
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
1233+
strLoadError = _("The block database contains a block which appears to be from the future. "
1234+
"This may be due to your computer's date and time being set incorrectly. "
1235+
"Only rebuild the block database if you are sure that your computer's date and time are correct");
1236+
break;
1237+
}
1238+
}
1239+
12281240
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
12291241
GetArg("-checkblocks", 288))) {
12301242
strLoadError = _("Corrupted block database detected");

0 commit comments

Comments
 (0)