Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 706 Lines • ▼ Show 20 Lines | gArgs.AddArg( | ||||
"level 3 checks disconnection of tip blocks, " | "level 3 checks disconnection of tip blocks, " | ||||
"and level 4 tries to reconnect the blocks. " | "and level 4 tries to reconnect the blocks. " | ||||
"Each level includes the checks of the previous levels " | "Each level includes the checks of the previous levels " | ||||
"(0-4, default: %u)", | "(0-4, default: %u)", | ||||
DEFAULT_CHECKLEVEL), | DEFAULT_CHECKLEVEL), | ||||
true, OptionsCategory::DEBUG_TEST); | true, OptionsCategory::DEBUG_TEST); | ||||
gArgs.AddArg("-checkblockindex", | gArgs.AddArg("-checkblockindex", | ||||
strprintf("Do a full consistency check for mapBlockIndex, " | strprintf("Do a full consistency check for mapBlockIndex, " | ||||
"setBlockIndexCandidates, chainActive and " | "setBlockIndexCandidates, ::ChainActive() and " | ||||
"mapBlocksUnlinked occasionally. (default: %u)", | "mapBlocksUnlinked occasionally. (default: %u)", | ||||
defaultChainParams->DefaultConsistencyChecks()), | defaultChainParams->DefaultConsistencyChecks()), | ||||
true, OptionsCategory::DEBUG_TEST); | true, OptionsCategory::DEBUG_TEST); | ||||
gArgs.AddArg("-checkmempool=<n>", | gArgs.AddArg("-checkmempool=<n>", | ||||
strprintf("Run checks every <n> transactions (default: %u)", | strprintf("Run checks every <n> transactions (default: %u)", | ||||
defaultChainParams->DefaultConsistencyChecks()), | defaultChainParams->DefaultConsistencyChecks()), | ||||
true, OptionsCategory::DEBUG_TEST); | true, OptionsCategory::DEBUG_TEST); | ||||
gArgs.AddArg("-checkpoints", | gArgs.AddArg("-checkpoints", | ||||
▲ Show 20 Lines • Show All 1,503 Lines • ▼ Show 20 Lines | while (!fLoaded && !ShutdownRequested()) { | ||||
} | } | ||||
// The on-disk coinsdb is now in a good state, create the cache | // The on-disk coinsdb is now in a good state, create the cache | ||||
pcoinsTip.reset(new CCoinsViewCache(pcoinscatcher.get())); | pcoinsTip.reset(new CCoinsViewCache(pcoinscatcher.get())); | ||||
bool is_coinsview_empty = fReset || fReindexChainState || | bool is_coinsview_empty = fReset || fReindexChainState || | ||||
pcoinsTip->GetBestBlock().IsNull(); | pcoinsTip->GetBestBlock().IsNull(); | ||||
if (!is_coinsview_empty) { | if (!is_coinsview_empty) { | ||||
// LoadChainTip sets chainActive based on pcoinsTip's best | // LoadChainTip sets ::ChainActive() based on pcoinsTip's | ||||
// block | // best block | ||||
if (!LoadChainTip(config)) { | if (!LoadChainTip(config)) { | ||||
strLoadError = _("Error initializing block database"); | strLoadError = _("Error initializing block database"); | ||||
break; | break; | ||||
} | } | ||||
assert(chainActive.Tip() != nullptr); | assert(::ChainActive().Tip() != nullptr); | ||||
uiInterface.InitMessage(_("Verifying blocks...")); | uiInterface.InitMessage(_("Verifying blocks...")); | ||||
if (fHavePruned && | if (fHavePruned && | ||||
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > | gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > | ||||
MIN_BLOCKS_TO_KEEP) { | MIN_BLOCKS_TO_KEEP) { | ||||
LogPrintf( | LogPrintf( | ||||
"Prune: pruned datadir may not have more than %d " | "Prune: pruned datadir may not have more than %d " | ||||
"blocks; only checking available blocks\n", | "blocks; only checking available blocks\n", | ||||
MIN_BLOCKS_TO_KEEP); | MIN_BLOCKS_TO_KEEP); | ||||
} | } | ||||
CBlockIndex *tip = chainActive.Tip(); | CBlockIndex *tip = ::ChainActive().Tip(); | ||||
RPCNotifyBlockChange(true, tip); | RPCNotifyBlockChange(true, tip); | ||||
if (tip && tip->nTime > | if (tip && tip->nTime > | ||||
GetAdjustedTime() + MAX_FUTURE_BLOCK_TIME) { | GetAdjustedTime() + MAX_FUTURE_BLOCK_TIME) { | ||||
strLoadError = _( | strLoadError = _( | ||||
"The block database contains a block which appears " | "The block database contains a block which appears " | ||||
"to be from the future. This may be due to your " | "to be from the future. This may be due to your " | ||||
"computer's date and time being set incorrectly. " | "computer's date and time being set incorrectly. " | ||||
"Only rebuild the block database if you are sure " | "Only rebuild the block database if you are sure " | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (!CheckDiskSpace(GetBlocksDir())) { | ||||
InitError( | InitError( | ||||
strprintf(_("Error: Disk space is low for %s"), GetBlocksDir())); | strprintf(_("Error: Disk space is low for %s"), GetBlocksDir())); | ||||
return false; | return false; | ||||
} | } | ||||
// Either install a handler to notify us when genesis activates, or set | // Either install a handler to notify us when genesis activates, or set | ||||
// fHaveGenesis directly. | // fHaveGenesis directly. | ||||
// No locking, as this happens before any background thread is started. | // No locking, as this happens before any background thread is started. | ||||
if (chainActive.Tip() == nullptr) { | if (::ChainActive().Tip() == nullptr) { | ||||
uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | uiInterface.NotifyBlockTip_connect(BlockNotifyGenesisWait); | ||||
} else { | } else { | ||||
fHaveGenesis = true; | fHaveGenesis = true; | ||||
} | } | ||||
if (gArgs.IsArgSet("-blocknotify")) { | if (gArgs.IsArgSet("-blocknotify")) { | ||||
uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | uiInterface.NotifyBlockTip_connect(BlockNotifyCallback); | ||||
} | } | ||||
Show All 25 Lines | #endif | ||||
// Step 12: start node | // Step 12: start node | ||||
int chain_active_height; | int chain_active_height; | ||||
//// debug print | //// debug print | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); | LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); | ||||
chain_active_height = chainActive.Height(); | chain_active_height = ::ChainActive().Height(); | ||||
} | } | ||||
LogPrintf("nBestHeight = %d\n", chain_active_height); | LogPrintf("nBestHeight = %d\n", chain_active_height); | ||||
if (gArgs.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) { | if (gArgs.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) { | ||||
StartTorControl(); | StartTorControl(); | ||||
} | } | ||||
Discover(); | Discover(); | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |