aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2018-03-09 12:12:43 +0800
committerJonas Schnelli <dev@jonasschnelli.ch>2018-03-11 12:37:20 +0800
commit386a6b62a8a1db9dd0f354cb95b7585f555c7e5d (patch)
tree4179dce98f66712dd2f266ed0568b8911cbf8831 /src/init.cpp
parented6ae8059cdbad60466807a7cfb23e5540a50051 (diff)
downloadbitcoin-386a6b62a8a1db9dd0f354cb95b7585f555c7e5d.tar.xz
Allow to optional specify the directory for the blocks storage
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp
index f763c3a435..eb8beda8d3 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -333,6 +333,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-version", _("Print version and exit"));
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
strUsage +=HelpMessageOpt("-assumevalid=<hex>", strprintf(_("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)"), defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()));
+ strUsage += HelpMessageOpt("-blocksdir=<dir>", _("Specify blocks directory (default: <datadir>/blocks)"));
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
strUsage += HelpMessageOpt("-blockreconstructionextratxn=<n>", strprintf(_("Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN));
if (showDebug)
@@ -596,7 +597,7 @@ void CleanupBlockRevFiles()
// Remove the rev files immediately and insert the blk file paths into an
// ordered map keyed by block file index.
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
- fs::path blocksdir = GetDataDir() / "blocks";
+ fs::path blocksdir = GetBlocksDir();
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
if (fs::is_regular_file(*it) &&
it->path().filename().string().length() == 12 &&
@@ -908,6 +909,10 @@ bool AppInitParameterInteraction()
// 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 (gArgs.GetArg("-prune", 0)) {
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX))
@@ -1630,7 +1635,7 @@ bool AppInitMain()
// ********************************************************* Step 10: import blocks
- if (!CheckDiskSpace())
+ if (!CheckDiskSpace() && !CheckDiskSpace(0, true))
return false;
// Either install a handler to notify us when genesis activates, or set fHaveGenesis directly.