mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 21:59:10 +02:00
Correct units for "-dbcache" and "-prune"
All dbcache-related values in the code are measured in MiB (not in megabytes, MB) or in bytes. The GUI "-prune" values in GB are translated to the node values in MiB correctly. The maximum of the "-prune" QSpinBox is not limited by the default value of 99 (GB). Also, this improves log readability.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -52,4 +52,7 @@ static const int MAX_URI_LENGTH = 255;
|
||||
#define QAPP_APP_NAME_TESTNET "Bitcoin-Qt-testnet"
|
||||
#define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest"
|
||||
|
||||
/* One gigabyte (GB) in bytes */
|
||||
static constexpr uint64_t GB_BYTES{1000000000};
|
||||
|
||||
#endif // BITCOIN_QT_GUICONSTANTS_H
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <qt/intro.h>
|
||||
#include <qt/forms/ui_intro.h>
|
||||
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <interfaces/node.h>
|
||||
@@ -21,7 +22,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
static const uint64_t GB_BYTES = 1000000000LL;
|
||||
/* Total required space (in GB) depending on user choice (prune, not prune) */
|
||||
static uint64_t requiredSpace;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <qt/forms/ui_optionsdialog.h>
|
||||
|
||||
#include <qt/bitcoinunits.h>
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/optionsmodel.h>
|
||||
|
||||
@@ -37,10 +38,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
||||
/* 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);
|
||||
@@ -161,6 +158,10 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
||||
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 here so init via mapper doesn't trigger them) */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <qt/optionsmodel.h>
|
||||
|
||||
#include <qt/bitcoinunits.h>
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <interfaces/node.h>
|
||||
@@ -92,10 +93,10 @@ void OptionsModel::Init(bool resetSettings)
|
||||
settings.setValue("bPrune", false);
|
||||
if (!settings.contains("nPruneSize"))
|
||||
settings.setValue("nPruneSize", 2);
|
||||
// Convert prune size to MB:
|
||||
const uint64_t nPruneSizeMB = settings.value("nPruneSize").toInt() * 1000;
|
||||
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMB) : "0")) {
|
||||
addOverriddenOption("-prune");
|
||||
// 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(nPruneSizeMiB) : "0")) {
|
||||
addOverriddenOption("-prune");
|
||||
}
|
||||
|
||||
if (!settings.contains("nDatabaseCache"))
|
||||
|
||||
Reference in New Issue
Block a user