Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,250 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void ThreadImport(const Config &config, | static void ThreadImport(const Config &config, | ||||
std::vector<fs::path> vImportFiles) { | std::vector<fs::path> vImportFiles) { | ||||
util::ThreadRename("loadblk"); | util::ThreadRename("loadblk"); | ||||
ScheduleBatchPriority(); | ScheduleBatchPriority(); | ||||
{ | { | ||||
const CChainParams &chainParams = config.GetChainParams(); | |||||
CImportingNow imp; | CImportingNow imp; | ||||
// -reindex | // -reindex | ||||
if (fReindex) { | if (fReindex) { | ||||
int nFile = 0; | int nFile = 0; | ||||
while (true) { | while (true) { | ||||
FlatFilePos pos(nFile, 0); | FlatFilePos pos(nFile, 0); | ||||
if (!fs::exists(GetBlockPosFilename(pos))) { | if (!fs::exists(GetBlockPosFilename(pos))) { | ||||
Show All 10 Lines | ScheduleBatchPriority(); | ||||
LoadExternalBlockFile(config, file, &pos); | LoadExternalBlockFile(config, file, &pos); | ||||
nFile++; | nFile++; | ||||
} | } | ||||
pblocktree->WriteReindexing(false); | pblocktree->WriteReindexing(false); | ||||
fReindex = false; | fReindex = false; | ||||
LogPrintf("Reindexing finished\n"); | LogPrintf("Reindexing finished\n"); | ||||
// To avoid ending up in a situation without genesis block, re-try | // To avoid ending up in a situation without genesis block, re-try | ||||
// initializing (no-op if reindexing worked): | // initializing (no-op if reindexing worked): | ||||
LoadGenesisBlock(config.GetChainParams()); | LoadGenesisBlock(chainParams); | ||||
} | } | ||||
// hardcoded $DATADIR/bootstrap.dat | // hardcoded $DATADIR/bootstrap.dat | ||||
fs::path pathBootstrap = GetDataDir() / "bootstrap.dat"; | fs::path pathBootstrap = GetDataDir() / "bootstrap.dat"; | ||||
if (fs::exists(pathBootstrap)) { | if (fs::exists(pathBootstrap)) { | ||||
FILE *file = fsbridge::fopen(pathBootstrap, "rb"); | FILE *file = fsbridge::fopen(pathBootstrap, "rb"); | ||||
if (file) { | if (file) { | ||||
fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; | fs::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; | ||||
Show All 13 Lines | ScheduleBatchPriority(); | ||||
LogPrintf("Importing blocks file %s...\n", path.string()); | LogPrintf("Importing blocks file %s...\n", path.string()); | ||||
LoadExternalBlockFile(config, file); | LoadExternalBlockFile(config, file); | ||||
} else { | } else { | ||||
LogPrintf("Warning: Could not open blocks file %s\n", | LogPrintf("Warning: Could not open blocks file %s\n", | ||||
path.string()); | path.string()); | ||||
} | } | ||||
} | } | ||||
// Reconsider blocks we know are valid. They may have been marked | |||||
// invalid by, for instance, running an outdated version of the node | |||||
// software. | |||||
const MapCheckpoints &checkpoints = | |||||
chainParams.Checkpoints().mapCheckpoints; | |||||
for (const MapCheckpoints::value_type &i : checkpoints) { | |||||
const BlockHash &hash = i.second; | |||||
LOCK(cs_main); | |||||
CBlockIndex *pblockindex = LookupBlockIndex(hash); | |||||
if (pblockindex && !pblockindex->nStatus.isValid()) { | |||||
LogPrintf("Reconsidering checkpointed block %s ...\n", | |||||
hash.GetHex()); | |||||
ResetBlockFailureFlags(pblockindex); | |||||
} | |||||
} | |||||
// scan for better chains in the block chain database, that are not yet | // scan for better chains in the block chain database, that are not yet | ||||
// connected in the active best chain | // connected in the active best chain | ||||
CValidationState state; | CValidationState state; | ||||
if (!ActivateBestChain(config, state)) { | if (!ActivateBestChain(config, state)) { | ||||
LogPrintf("Failed to connect best block (%s)\n", | LogPrintf("Failed to connect best block (%s)\n", | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
StartShutdown(); | StartShutdown(); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 1,367 Lines • Show Last 20 Lines |