Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | std::string HelpMessage(HelpMessageMode mode) { | ||||
// to translators. | // to translators. | ||||
std::string strUsage = HelpMessageGroup(_("Options:")); | std::string strUsage = HelpMessageGroup(_("Options:")); | ||||
strUsage += HelpMessageOpt("-?", _("Print this help message and exit")); | strUsage += HelpMessageOpt("-?", _("Print this help message and exit")); | ||||
strUsage += HelpMessageOpt("-version", _("Print version and exit")); | strUsage += HelpMessageOpt("-version", _("Print version and exit")); | ||||
strUsage += HelpMessageOpt( | strUsage += HelpMessageOpt( | ||||
"-alertnotify=<cmd>", | "-alertnotify=<cmd>", | ||||
_("Execute command when a relevant alert is received or we see a " | _("Execute command when a relevant alert is received or we see a " | ||||
"really long fork (%s in cmd is replaced by message)")); | "really long fork (%s in cmd is replaced by message)")); | ||||
strUsage += HelpMessageOpt( | |||||
"-blocksdir=<dir>", | |||||
_("Specify blocks directory (default: <datadir>/blocks)")); | |||||
strUsage += HelpMessageOpt("-blocknotify=<cmd>", | strUsage += HelpMessageOpt("-blocknotify=<cmd>", | ||||
_("Execute command when the best block changes " | _("Execute command when the best block changes " | ||||
"(%s in cmd is replaced by block hash)")); | "(%s in cmd is replaced by block hash)")); | ||||
if (showDebug) { | if (showDebug) { | ||||
strUsage += HelpMessageOpt( | strUsage += HelpMessageOpt( | ||||
"-blocksonly", | "-blocksonly", | ||||
strprintf( | strprintf( | ||||
_("Whether to operate in a blocks only mode (default: %d)"), | _("Whether to operate in a blocks only mode (default: %d)"), | ||||
▲ Show 20 Lines • Show All 652 Lines • ▼ Show 20 Lines | |||||
void CleanupBlockRevFiles() { | 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"); | ||||
fs::path blocksdir = GetDataDir() / "blocks"; | fs::path blocksdir = GetBlocksDir(); | ||||
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); | for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); | ||||
it++) { | it++) { | ||||
if (is_regular_file(*it) && | if (is_regular_file(*it) && | ||||
it->path().filename().string().length() == 12 && | it->path().filename().string().length() == 12 && | ||||
it->path().filename().string().substr(8, 4) == ".dat") { | it->path().filename().string().substr(8, 4) == ".dat") { | ||||
if (it->path().filename().string().substr(0, 3) == "blk") { | if (it->path().filename().string().substr(0, 3) == "blk") { | ||||
mapBlockFiles[it->path().filename().string().substr(3, 5)] = | mapBlockFiles[it->path().filename().string().substr(3, 5)] = | ||||
it->path(); | it->path(); | ||||
▲ Show 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool AppInitParameterInteraction(Config &config, RPCServer &rpcServer) { | bool AppInitParameterInteraction(Config &config, RPCServer &rpcServer) { | ||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
// Step 2: parameter interactions | // Step 2: parameter interactions | ||||
// also see: InitParameterInteraction() | // also see: InitParameterInteraction() | ||||
if (!fs::is_directory(GetBlocksDir(false))) { | |||||
return InitError( | |||||
strprintf(_("Specified blocks directory \"%s\" does not exist.\n"), | |||||
gArgs.GetArg("-blocksdir", "").c_str())); | |||||
} | |||||
// if using block pruning, then disallow txindex | // if using block pruning, then disallow txindex | ||||
if (gArgs.GetArg("-prune", 0)) { | if (gArgs.GetArg("-prune", 0)) { | ||||
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { | ||||
return InitError(_("Prune mode is incompatible with -txindex.")); | return InitError(_("Prune mode is incompatible with -txindex.")); | ||||
} | } | ||||
} | } | ||||
// if space reserved for high priority transactions is misconfigured | // if space reserved for high priority transactions is misconfigured | ||||
▲ Show 20 Lines • Show All 856 Lines • ▼ Show 20 Lines | if (fPruneMode) { | ||||
nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK); | nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK); | ||||
if (!fReindex) { | if (!fReindex) { | ||||
uiInterface.InitMessage(_("Pruning blockstore...")); | uiInterface.InitMessage(_("Pruning blockstore...")); | ||||
PruneAndFlush(); | PruneAndFlush(); | ||||
} | } | ||||
} | } | ||||
// Step 10: import blocks | // Step 10: import blocks | ||||
if (!CheckDiskSpace()) { | if (!CheckDiskSpace(/* additional_bytes */ 0, /* blocks_dir */ false)) { | ||||
InitError( | |||||
strprintf(_("Error: Disk space is low for %s"), GetDataDir())); | |||||
return false; | |||||
} | |||||
if (!CheckDiskSpace(/* additional_bytes */ 0, /* blocks_dir */ true)) { | |||||
InitError( | |||||
strprintf(_("Error: Disk space is low for %s"), GetBlocksDir())); | |||||
return false; | return false; | ||||
} | } | ||||
jasonbcox: In the future, please don't do this unless the fix is strictly necessary. You can have two… | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsOK, recalibrating. :-) markblundeberg: OK, recalibrating. :-) | |||||
// 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; | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |
In the future, please don't do this unless the fix is strictly necessary. You can have two separate diffs get reviewed and wait to land them around the same time after they are both green'd.