Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 2,037 Lines • ▼ Show 20 Lines | #endif | ||||
int64_t nStart = 0; | int64_t nStart = 0; | ||||
bool fLoaded = false; | bool fLoaded = false; | ||||
while (!fLoaded && !fRequestShutdown) { | while (!fLoaded && !fRequestShutdown) { | ||||
bool fReset = fReindex; | bool fReset = fReindex; | ||||
std::string strLoadError; | std::string strLoadError; | ||||
uiInterface.InitMessage(_("Loading block index...")); | uiInterface.InitMessage(_("Loading block index...")); | ||||
LOCK(cs_main); | |||||
nStart = GetTimeMillis(); | nStart = GetTimeMillis(); | ||||
do { | do { | ||||
try { | try { | ||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
pcoinsTip.reset(); | pcoinsTip.reset(); | ||||
pcoinsdbview.reset(); | pcoinsdbview.reset(); | ||||
pcoinscatcher.reset(); | pcoinscatcher.reset(); | ||||
pblocktree.reset( | pblocktree.reset( | ||||
Show All 19 Lines | while (!fLoaded && !fRequestShutdown) { | ||||
strLoadError = _("Error loading block database"); | strLoadError = _("Error loading block database"); | ||||
break; | break; | ||||
} | } | ||||
// If the loaded chain has a wrong genesis, bail out immediately | // If the loaded chain has a wrong genesis, bail out immediately | ||||
// (we're likely using a testnet datadir, or the other way | // (we're likely using a testnet datadir, or the other way | ||||
// around). | // around). | ||||
if (!mapBlockIndex.empty() && | if (!mapBlockIndex.empty() && | ||||
mapBlockIndex.count( | !LookupBlockIndex( | ||||
chainparams.GetConsensus().hashGenesisBlock) == 0) { | chainparams.GetConsensus().hashGenesisBlock)) { | ||||
return InitError(_("Incorrect or no genesis block found. " | return InitError(_("Incorrect or no genesis block found. " | ||||
"Wrong datadir for network?")); | "Wrong datadir for network?")); | ||||
} | } | ||||
// Check for changed -txindex state | // Check for changed -txindex state | ||||
if (fTxIndex != gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | if (fTxIndex != gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | ||||
strLoadError = _("You need to rebuild the database using " | strLoadError = _("You need to rebuild the database using " | ||||
"-reindex-chainstate to change -txindex"); | "-reindex-chainstate to change -txindex"); | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | while (!fLoaded && !fRequestShutdown) { | ||||
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > | gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > | ||||
MIN_BLOCKS_TO_KEEP) { | MIN_BLOCKS_TO_KEEP) { | ||||
LogPrintf("Prune: pruned datadir may not have more " | LogPrintf("Prune: pruned datadir may not have more " | ||||
"than %d blocks; only checking available " | "than %d blocks; only checking available " | ||||
"blocks", | "blocks", | ||||
MIN_BLOCKS_TO_KEEP); | MIN_BLOCKS_TO_KEEP); | ||||
} | } | ||||
{ | |||||
LOCK(cs_main); | |||||
CBlockIndex *tip = chainActive.Tip(); | CBlockIndex *tip = chainActive.Tip(); | ||||
RPCNotifyBlockChange(true, tip); | RPCNotifyBlockChange(true, tip); | ||||
if (tip && tip->nTime > GetAdjustedTime() + | if (tip && tip->nTime > | ||||
MAX_FUTURE_BLOCK_TIME) { | GetAdjustedTime() + MAX_FUTURE_BLOCK_TIME) { | ||||
strLoadError = | strLoadError = _( | ||||
_("The block database contains a block which " | "The block database contains a block which appears " | ||||
"appears to be from the future. This may be " | "to be from the future. This may be due to your " | ||||
"due to your computer's date and time being " | "computer's date and time being set incorrectly. " | ||||
"set incorrectly. Only rebuild the block " | "Only rebuild the block database if you are sure " | ||||
"database if you are sure that your " | "that your computer's date and time are correct"); | ||||
"computer's date and time are correct"); | |||||
break; | break; | ||||
} | } | ||||
} | |||||
if (!CVerifyDB().VerifyDB( | if (!CVerifyDB().VerifyDB( | ||||
config, pcoinsdbview.get(), | config, pcoinsdbview.get(), | ||||
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL), | gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL), | ||||
gArgs.GetArg("-checkblocks", | gArgs.GetArg("-checkblocks", | ||||
DEFAULT_CHECKBLOCKS))) { | DEFAULT_CHECKBLOCKS))) { | ||||
strLoadError = _("Corrupted block database detected"); | strLoadError = _("Corrupted block database detected"); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines |