diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -430,9 +430,8 @@ OptionsCategory::OPTIONS); gArgs.AddArg( "-dbcache=", - strprintf( - "Set database cache size in megabytes (%d to %d, default: %d)", - nMinDbCache, nMaxDbCache, nDefaultDbCache), + strprintf("Set database cache size in MiB (%d to %d, default: %d)", + nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-debuglogfile=", strprintf("Specify location of debug log file. Relative paths " @@ -1854,8 +1853,8 @@ .translated, MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); } - LogPrintf("Prune configured to target %uMiB on disk for block and undo " - "files.\n", + LogPrintf("Prune configured to target %u MiB on disk for block and " + "undo files.\n", nPruneTarget / 1024 / 1024); fPruneMode = true; } @@ -2363,10 +2362,10 @@ int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; LogPrintf("Cache configuration:\n"); - LogPrintf("* Using %.1fMiB for block index database\n", + LogPrintf("* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024)); if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { - LogPrintf("* Using %.1fMiB for transaction index database\n", + LogPrintf("* Using %.1f MiB for transaction index database\n", nTxIndexCache * (1.0 / 1024 / 1024)); } for (BlockFilterType filter_type : g_enabled_filter_types) { @@ -2374,9 +2373,9 @@ filter_index_cache * (1.0 / 1024 / 1024), BlockFilterTypeName(filter_type)); } - LogPrintf("* Using %.1fMiB for chain state database\n", + LogPrintf("* Using %.1f MiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024)); - LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of " + LogPrintf("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of " "unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024)); diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -121,7 +121,7 @@ - MB + MiB Qt::PlainText diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -48,4 +48,7 @@ #define QAPP_APP_NAME_TESTNET "BitcoinABC-Qt-testnet" #define QAPP_APP_NAME_REGTEST "BitcoinABC-Qt-regtest" +/* One gigabyte (GB) in bytes */ +static constexpr uint64_t GB_BYTES{1'000'000'000}; + #endif // BITCOIN_QT_GUICONSTANTS_H diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include -static const uint64_t GB_BYTES = 1000000000LL; /** * Total required space (in GB) depending on user choice (prune, not prune). */ diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include // for -dbcache defaults @@ -33,13 +34,6 @@ /* Main elements init */ ui->databaseCache->setMinimum(nMinDbCache); ui->databaseCache->setMaximum(nMaxDbCache); - static const uint64_t GiB = 1024 * 1024 * 1024; - static const uint64_t nMinDiskSpace = - MIN_DISK_SPACE_FOR_BLOCK_FILES / GiB + - (MIN_DISK_SPACE_FOR_BLOCK_FILES % GiB) - ? 1 - : 0; - ui->pruneSize->setMinimum(nMinDiskSpace); ui->threadsScriptVerif->setMinimum(-GetNumCores()); ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS); ui->pruneWarning->setVisible(false); @@ -178,6 +172,15 @@ mapper->toFirst(); updateDefaultProxyNets(); + + // Prune values are in GB to be consistent with intro.cpp + static constexpr uint64_t nMinDiskSpace = + (MIN_DISK_SPACE_FOR_BLOCK_FILES / GB_BYTES) + + (MIN_DISK_SPACE_FOR_BLOCK_FILES % GB_BYTES) + ? 1 + : 0; + ui->pruneSize->setRange(nMinDiskSpace, + _model->node().getAssumedBlockchainSize()); } /* warn when one of the following settings changes by user action (placed diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include // for -dbcache defaults @@ -103,10 +104,11 @@ if (!settings.contains("nPruneSize")) { settings.setValue("nPruneSize", 2); } - // Convert prune size to MB: - const uint64_t nPruneSizeMB = settings.value("nPruneSize").toInt() * 1000; + // Convert prune size from GB to MiB: + const uint64_t nPruneSizeMiB = + (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20; if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() - ? std::to_string(nPruneSizeMB) + ? std::to_string(nPruneSizeMiB) : "0")) { addOverriddenOption("-prune"); } diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -229,16 +229,17 @@ static const unsigned int DEFAULT_CHECKLEVEL = 3; /** - * Require that user allocate at least 550MB for block & undo files (blk???.dat - * and rev???.dat) + * Require that user allocate at least 550 MiB for block & undo files + * (blk???.dat and rev???.dat) * At 1MB per block, 288 blocks = 288MB. * Add 15% for Undo data = 331MB * Add 20% for Orphan block rate = 397MB * We want the low water mark after pruning to be at least 397 MB and since we * prune in full block file chunks, we need the high water mark which triggers * the prune to be one 128MB block file + added 15% undo data = 147MB greater - * for a total of 545MB. Setting the target to > than 550MB will make it likely - * we can respect the target. + * for a total of 545MB + * Setting the target to >= 550 MiB will make it likely we can respect the + * target. */ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -377,7 +377,7 @@ assert not has_block( 3), "blk00003.dat is still there, should be pruned by now" - # stop node, start back up with auto-prune at 550MB, make sure still + # stop node, start back up with auto-prune at 550 MiB, make sure still # runs self.stop_node(node_number) self.start_node(node_number, extra_args=["-prune=550"])