Page MenuHomePhabricator

D7781.diff
No OneTemporary

D7781.diff

diff --git a/src/init.cpp b/src/init.cpp
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -428,9 +428,8 @@
OptionsCategory::OPTIONS);
gArgs.AddArg(
"-dbcache=<n>",
- 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=<file>",
strprintf("Specify location of debug log file. Relative paths "
@@ -1852,9 +1851,10 @@
.translated,
MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
}
- LogPrintf("Prune configured to target %uMiB on disk for block and undo "
- "files.\n",
- nPruneTarget / 1024 / 1024);
+ LogPrintf(
+ "Prune configured to target %u MiB on disk for block and undo "
+ "files.\n",
+ nPruneTarget / 1024 / 1024);
fPruneMode = true;
}
@@ -2361,10 +2361,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) {
@@ -2372,9 +2372,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 @@
<item>
<widget class="QLabel" name="databaseCacheUnitLabel">
<property name="text">
- <string>MB</string>
+ <string>MiB</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h
--- a/src/qt/guiconstants.h
+++ b/src/qt/guiconstants.h
@@ -54,4 +54,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{1000000000};
+
#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,8 @@
#include <fs.h>
#include <interfaces/node.h>
#include <qt/forms/ui_intro.h>
+
+#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/intro.h>
#include <util/system.h>
@@ -19,7 +21,6 @@
#include <cmath>
-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 <interfaces/node.h>
#include <netbase.h>
#include <qt/bitcoinunits.h>
+#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/optionsmodel.h>
#include <txdb.h> // 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);
@@ -167,6 +161,15 @@
showRestartWarning(true);
}
+ // 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());
+
QString strLabel = _model->getOverriddenByCommandLine();
if (strLabel.isEmpty()) {
strLabel = tr("none");
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 <net.h>
#include <netbase.h>
#include <qt/bitcoinunits.h>
+#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/intro.h>
#include <txdb.h> // 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,7 +229,7 @@
static const unsigned int DEFAULT_CHECKLEVEL = 3;
/**
- * Require that user allocate at least 550MB for block & undo files (blk???.dat
+ * Require that user allocate at least 550MiB for block & undo files (blk???.dat
* and rev???.dat)
* At 1MB per block, 288 blocks = 288MB.
* Add 15% for Undo data = 331MB
@@ -237,7 +237,7 @@
* 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
+ * for a total of 545MB. Setting the target to > than 550MiB 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"])

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 12:21 (16 m, 40 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5184827
Default Alt Text
D7781.diff (7 KB)

Event Timeline