Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,366 Lines • ▼ Show 20 Lines | |||||
static void CleanupBlockRevFiles() { | static void CleanupBlockRevFiles() { | ||||
std::map<std::string, fs::path> mapBlockFiles; | std::map<std::string, fs::path> mapBlockFiles; | ||||
// Glob all blk?????.dat and rev?????.dat files from the blocks directory. | // Glob all blk?????.dat and rev?????.dat files from the blocks directory. | ||||
// Remove the rev files immediately and insert the blk file paths into an | // Remove the rev files immediately and insert the blk file paths into an | ||||
// ordered map keyed by block file index. | // ordered map keyed by block file index. | ||||
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for " | LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for " | ||||
"-reindex with -prune\n"); | "-reindex with -prune\n"); | ||||
const auto directoryIterator = fs::directory_iterator{GetBlocksDir()}; | for (const auto &file : fs::directory_iterator{gArgs.GetBlocksDirPath()}) { | ||||
for (const auto &file : directoryIterator) { | |||||
const auto fileName = file.path().filename().string(); | const auto fileName = file.path().filename().string(); | ||||
if (fs::is_regular_file(file) && fileName.length() == 12 && | if (fs::is_regular_file(file) && fileName.length() == 12 && | ||||
fileName.substr(8, 4) == ".dat") { | fileName.substr(8, 4) == ".dat") { | ||||
if (fileName.substr(0, 3) == "blk") { | if (fileName.substr(0, 3) == "blk") { | ||||
mapBlockFiles[fileName.substr(3, 5)] = file.path(); | mapBlockFiles[fileName.substr(3, 5)] = file.path(); | ||||
} else if (fileName.substr(0, 3) == "rev") { | } else if (fileName.substr(0, 3) == "rev") { | ||||
remove(file.path()); | remove(file.path()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 408 Lines • ▼ Show 20 Lines | for (const auto §ion : args.GetUnrecognizedSections()) { | ||||
Untranslated("\n"), | Untranslated("\n"), | ||||
section.m_file, section.m_line, section.m_name); | section.m_file, section.m_line, section.m_name); | ||||
} | } | ||||
if (!warnings.empty()) { | if (!warnings.empty()) { | ||||
InitWarning(warnings); | InitWarning(warnings); | ||||
} | } | ||||
if (!fs::is_directory(GetBlocksDir())) { | if (!fs::is_directory(gArgs.GetBlocksDirPath())) { | ||||
return InitError( | return InitError( | ||||
strprintf(_("Specified blocks directory \"%s\" does not exist."), | strprintf(_("Specified blocks directory \"%s\" does not exist."), | ||||
args.GetArg("-blocksdir", ""))); | args.GetArg("-blocksdir", ""))); | ||||
} | } | ||||
// parse and validate enabled filter types | // parse and validate enabled filter types | ||||
std::string blockfilterindex_value = | std::string blockfilterindex_value = | ||||
args.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX); | args.GetArg("-blockfilterindex", DEFAULT_BLOCKFILTERINDEX); | ||||
▲ Show 20 Lines • Show All 1,080 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
// Step 11: import blocks | // Step 11: import blocks | ||||
if (!CheckDiskSpace(GetDataDir())) { | if (!CheckDiskSpace(GetDataDir())) { | ||||
InitError( | InitError( | ||||
strprintf(_("Error: Disk space is low for %s"), GetDataDir())); | strprintf(_("Error: Disk space is low for %s"), GetDataDir())); | ||||
return false; | return false; | ||||
} | } | ||||
if (!CheckDiskSpace(GetBlocksDir())) { | if (!CheckDiskSpace(gArgs.GetBlocksDirPath())) { | ||||
InitError( | InitError(strprintf(_("Error: Disk space is low for %s"), | ||||
strprintf(_("Error: Disk space is low for %s"), GetBlocksDir())); | gArgs.GetBlocksDirPath())); | ||||
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. | ||||
boost::signals2::connection block_notify_genesis_wait_connection; | boost::signals2::connection block_notify_genesis_wait_connection; | ||||
if (::ChainActive().Tip() == nullptr) { | if (::ChainActive().Tip() == nullptr) { | ||||
▲ Show 20 Lines • Show All 205 Lines • Show Last 20 Lines |