Qt/Options: Switch prune setting from GB to MiB

This commit is contained in:
Luke Dashjr 2023-08-03 19:22:39 +00:00
parent 3a2e18081a
commit a28c48bc4c
9 changed files with 56 additions and 66 deletions

View File

@ -340,7 +340,7 @@ void BitcoinApplication::parameterSetup()
void BitcoinApplication::InitPruneSetting(int64_t prune_MiB) void BitcoinApplication::InitPruneSetting(int64_t prune_MiB)
{ {
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB)); optionsModel->SetPruneTargetMiB(prune_MiB);
} }
void BitcoinApplication::requestInitialize() void BitcoinApplication::requestInitialize()

View File

@ -243,16 +243,16 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="pruneGB"> <widget class="QSpinBox" name="pruneMiB">
<property name="suffix"> <property name="suffix">
<string> GB</string> <string> MiB</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="lblPruneSuffix"> <widget class="QLabel" name="lblPruneSuffix">
<property name="buddy"> <property name="buddy">
<cstring>pruneGB</cstring> <cstring>pruneMiB</cstring>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -63,12 +63,12 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="pruneSize"/> <widget class="QSpinBox" name="pruneSizeMiB"/>
</item> </item>
<item> <item>
<widget class="QLabel" name="pruneSizeUnitLabel"> <widget class="QLabel" name="pruneSizeUnitLabel">
<property name="text"> <property name="text">
<string>GB</string> <string>MiB</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::PlainText</enum> <enum>Qt::PlainText</enum>

View File

@ -54,10 +54,13 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
#define QAPP_APP_NAME_SIGNET "Bitcoin-Qt-signet" #define QAPP_APP_NAME_SIGNET "Bitcoin-Qt-signet"
#define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest" #define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest"
/* One mebibyte (MiB) in bytes */
static constexpr uint64_t MiB_BYTES{1024 * 1024};
/* One gigabyte (GB) in bytes */ /* One gigabyte (GB) in bytes */
static constexpr uint64_t GB_BYTES{1000000000}; static constexpr uint64_t GB_BYTES{1000000000};
// Default prune target displayed in GUI. // Default prune target displayed in GUI.
static constexpr int DEFAULT_PRUNE_TARGET_GB{2}; static constexpr int DEFAULT_PRUNE_TARGET_MiB{1907};
#endif // BITCOIN_QT_GUICONSTANTS_H #endif // BITCOIN_QT_GUICONSTANTS_H

View File

@ -111,11 +111,11 @@ void FreespaceChecker::check()
namespace { namespace {
//! Return pruning size that will be used if automatic pruning is enabled. //! Return pruning size that will be used if automatic pruning is enabled.
int GetPruneTargetGB() int GetPruneTargetMiB()
{ {
int64_t prune_target_mib = gArgs.GetIntArg("-prune", 0); int64_t prune_target_mib = gArgs.GetIntArg("-prune", 0);
// >1 means automatic pruning is enabled by config, 1 means manual pruning, 0 means no pruning. // >1 means automatic pruning is enabled by config, 1 means manual pruning, 0 means no pruning.
return prune_target_mib > 1 ? PruneMiBtoGB(prune_target_mib) : DEFAULT_PRUNE_TARGET_GB; return prune_target_mib > 1 ? prune_target_mib : DEFAULT_PRUNE_TARGET_MiB;
} }
} // namespace } // namespace
@ -124,7 +124,7 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
ui(new Ui::Intro), ui(new Ui::Intro),
m_blockchain_size_gb(blockchain_size_gb), m_blockchain_size_gb(blockchain_size_gb),
m_chain_state_size_gb(chain_state_size_gb), m_chain_state_size_gb(chain_state_size_gb),
m_prune_target_gb{GetPruneTargetGB()} m_prune_target_mib{GetPruneTargetMiB()}
{ {
ui->setupUi(this); ui->setupUi(this);
ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(PACKAGE_NAME)); ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(PACKAGE_NAME));
@ -138,15 +138,15 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
); );
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME)); ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME));
const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9); const int min_prune_target_MiB = (MIN_DISK_SPACE_FOR_BLOCK_FILES + MiB_BYTES - 1) / MiB_BYTES;
ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max()); ui->pruneMiB->setRange(min_prune_target_MiB, std::numeric_limits<int>::max());
if (gArgs.IsArgSet("-prune")) { if (gArgs.IsArgSet("-prune")) {
m_prune_checkbox_is_default = false; m_prune_checkbox_is_default = false;
ui->prune->setChecked(gArgs.GetIntArg("-prune", 0) >= 1); ui->prune->setChecked(gArgs.GetIntArg("-prune", 0) >= 1);
ui->prune->setEnabled(false); ui->prune->setEnabled(false);
} }
ui->pruneGB->setValue(m_prune_target_gb); ui->pruneMiB->setValue(m_prune_target_mib);
ui->pruneGB->setToolTip(ui->prune->toolTip()); ui->pruneMiB->setToolTip(ui->prune->toolTip());
ui->lblPruneSuffix->setToolTip(ui->prune->toolTip()); ui->lblPruneSuffix->setToolTip(ui->prune->toolTip());
UpdatePruneLabels(ui->prune->isChecked()); UpdatePruneLabels(ui->prune->isChecked());
@ -155,8 +155,8 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
UpdatePruneLabels(prune_checked); UpdatePruneLabels(prune_checked);
UpdateFreeSpaceLabel(); UpdateFreeSpaceLabel();
}); });
connect(ui->pruneGB, qOverload<int>(&QSpinBox::valueChanged), [this](int prune_GB) { connect(ui->pruneMiB, qOverload<int>(&QSpinBox::valueChanged), [this](int prune_MiB) {
m_prune_target_gb = prune_GB; m_prune_target_mib = prune_MiB;
UpdatePruneLabels(ui->prune->isChecked()); UpdatePruneLabels(ui->prune->isChecked());
UpdateFreeSpaceLabel(); UpdateFreeSpaceLabel();
}); });
@ -196,7 +196,7 @@ int64_t Intro::getPruneMiB() const
{ {
switch (ui->prune->checkState()) { switch (ui->prune->checkState()) {
case Qt::Checked: case Qt::Checked:
return PruneGBtoMiB(m_prune_target_gb); return m_prune_target_mib;
case Qt::Unchecked: default: case Qt::Unchecked: default:
return 0; return 0;
} }
@ -376,14 +376,15 @@ void Intro::UpdatePruneLabels(bool prune_checked)
{ {
m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb; m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
if (prune_checked && m_prune_target_gb <= m_blockchain_size_gb) { const int64_t prune_target_gb = (m_prune_target_mib * MiB_BYTES + GB_BYTES - 1) / GB_BYTES;
m_required_space_gb = m_prune_target_gb + m_chain_state_size_gb; if (prune_checked && prune_target_gb <= m_blockchain_size_gb) {
m_required_space_gb = prune_target_gb + m_chain_state_size_gb;
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory."); storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
} }
ui->pruneGB->setEnabled(prune_checked); ui->pruneMiB->setEnabled(prune_checked);
static constexpr uint64_t nPowTargetSpacing = 10 * 60; // from chainparams, which we don't have at this stage static constexpr uint64_t nPowTargetSpacing = 10 * 60; // from chainparams, which we don't have at this stage
static constexpr uint32_t expected_block_data_size = 2250000; // includes undo data static constexpr uint32_t expected_block_data_size = 2250000; // includes undo data
const uint64_t expected_backup_days = m_prune_target_gb * 1e9 / (uint64_t(expected_block_data_size) * 86400 / nPowTargetSpacing); const uint64_t expected_backup_days = m_prune_target_mib * MiB_BYTES / (uint64_t(expected_block_data_size) * 86400 / nPowTargetSpacing);
ui->lblPruneSuffix->setText( ui->lblPruneSuffix->setText(
//: Explanatory text on the capability of the current prune target. //: Explanatory text on the capability of the current prune target.
tr("(sufficient to restore backups %n day(s) old)", "", expected_backup_days)); tr("(sufficient to restore backups %n day(s) old)", "", expected_backup_days));

View File

@ -74,7 +74,7 @@ private:
//! Total required space (in GB) depending on user choice (prune or not prune). //! Total required space (in GB) depending on user choice (prune or not prune).
int64_t m_required_space_gb{0}; int64_t m_required_space_gb{0};
uint64_t m_bytes_available{0}; uint64_t m_bytes_available{0};
int64_t m_prune_target_gb; int64_t m_prune_target_mib;
void startThread(); void startThread();
void checkPath(const QString &dataDir); void checkPath(const QString &dataDir);

View File

@ -102,8 +102,8 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
ui->pruneWarning->setVisible(false); ui->pruneWarning->setVisible(false);
ui->pruneWarning->setStyleSheet("QLabel { color: red; }"); ui->pruneWarning->setStyleSheet("QLabel { color: red; }");
ui->pruneSize->setEnabled(false); ui->pruneSizeMiB->setEnabled(false);
connect(ui->prune, &QPushButton::toggled, ui->pruneSize, &QWidget::setEnabled); connect(ui->prune, &QPushButton::toggled, ui->pruneSizeMiB, &QWidget::setEnabled);
ui->networkPort->setValidator(new QIntValidator(1024, 65535, this)); ui->networkPort->setValidator(new QIntValidator(1024, 65535, this));
connect(ui->networkPort, SIGNAL(textChanged(const QString&)), this, SLOT(checkLineEdit())); connect(ui->networkPort, SIGNAL(textChanged(const QString&)), this, SLOT(checkLineEdit()));
@ -243,9 +243,8 @@ void OptionsDialog::setModel(OptionsModel *_model)
if (_model->isRestartRequired()) if (_model->isRestartRequired())
showRestartWarning(true); showRestartWarning(true);
// Prune values are in GB to be consistent with intro.cpp static constexpr uint64_t nMinDiskSpace = (MIN_DISK_SPACE_FOR_BLOCK_FILES + MiB_BYTES - 1) / MiB_BYTES;
static constexpr uint64_t nMinDiskSpace = (MIN_DISK_SPACE_FOR_BLOCK_FILES / GB_BYTES) + (MIN_DISK_SPACE_FOR_BLOCK_FILES % GB_BYTES) ? 1 : 0; ui->pruneSizeMiB->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
QString strLabel = _model->getOverriddenByCommandLine(); QString strLabel = _model->getOverriddenByCommandLine();
if (strLabel.isEmpty()) if (strLabel.isEmpty())
@ -270,7 +269,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
/* Main */ /* Main */
connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::togglePruneWarning); connect(ui->prune, &QCheckBox::clicked, this, &OptionsDialog::togglePruneWarning);
connect(ui->pruneSize, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning); connect(ui->pruneSizeMiB, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->databaseCache, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning); connect(ui->databaseCache, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->externalSignerPath, &QLineEdit::textChanged, [this]{ showRestartWarning(); }); connect(ui->externalSignerPath, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
connect(ui->threadsScriptVerif, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning); connect(ui->threadsScriptVerif, qOverload<int>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
@ -305,7 +304,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif); mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache); mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
mapper->addMapping(ui->prune, OptionsModel::Prune); mapper->addMapping(ui->prune, OptionsModel::Prune);
mapper->addMapping(ui->pruneSize, OptionsModel::PruneSize); mapper->addMapping(ui->pruneSizeMiB, OptionsModel::PruneSizeMiB);
/* Wallet */ /* Wallet */
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange); mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);

View File

@ -53,7 +53,7 @@ static const char* SettingName(OptionsModel::OptionID option)
case OptionsModel::MapPortNatpmp: return "natpmp"; case OptionsModel::MapPortNatpmp: return "natpmp";
case OptionsModel::Listen: return "listen"; case OptionsModel::Listen: return "listen";
case OptionsModel::Server: return "server"; case OptionsModel::Server: return "server";
case OptionsModel::PruneSize: return "prune"; case OptionsModel::PruneSizeMiB: return "prune";
case OptionsModel::Prune: return "prune"; case OptionsModel::Prune: return "prune";
case OptionsModel::ProxyIP: return "proxy"; case OptionsModel::ProxyIP: return "proxy";
case OptionsModel::ProxyPort: return "proxy"; case OptionsModel::ProxyPort: return "proxy";
@ -73,7 +73,7 @@ static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID optio
(option == OptionsModel::DatabaseCache || (option == OptionsModel::DatabaseCache ||
option == OptionsModel::ThreadsScriptVerif || option == OptionsModel::ThreadsScriptVerif ||
option == OptionsModel::Prune || option == OptionsModel::Prune ||
option == OptionsModel::PruneSize)) { option == OptionsModel::PruneSizeMiB)) {
// Write certain old settings as strings, even though they are numbers, // Write certain old settings as strings, even though they are numbers,
// because Bitcoin 22.x releases try to read these specific settings as // because Bitcoin 22.x releases try to read these specific settings as
// strings in addOverriddenOption() calls at startup, triggering // strings in addOverriddenOption() calls at startup, triggering
@ -88,10 +88,10 @@ static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID optio
} }
//! Convert enabled/size values to bitcoin -prune setting. //! Convert enabled/size values to bitcoin -prune setting.
static common::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb) static common::SettingsValue PruneSettingFromMiB(bool prune_enabled, int prune_size_mib)
{ {
assert(!prune_enabled || prune_size_gb >= 1); // PruneSizeGB and ParsePruneSizeGB never return less assert(!prune_enabled || prune_size_mib >= 1); // PruneSizeMiB and ParsePruneSizeMiB never return less
return prune_enabled ? PruneGBtoMiB(prune_size_gb) : 0; return prune_enabled ? prune_size_mib : 0;
} }
//! Get pruning enabled value to show in GUI from bitcoin -prune setting. //! Get pruning enabled value to show in GUI from bitcoin -prune setting.
@ -103,18 +103,10 @@ static bool PruneEnabled(const common::SettingsValue& prune_setting)
//! Get pruning size value to show in GUI from bitcoin -prune setting. If //! Get pruning size value to show in GUI from bitcoin -prune setting. If
//! pruning is not enabled, just show default recommended pruning size (2GB). //! pruning is not enabled, just show default recommended pruning size (2GB).
static int PruneSizeGB(const common::SettingsValue& prune_setting) static int PruneSizeAsMiB(const common::SettingsValue& prune_setting)
{ {
int value = SettingToInt(prune_setting, 0); int value = SettingToInt(prune_setting, 0);
return value > 1 ? PruneMiBtoGB(value) : DEFAULT_PRUNE_TARGET_GB; return value > 1 ? value : DEFAULT_PRUNE_TARGET_MiB;
}
//! Parse pruning size value provided by user in GUI or loaded from QSettings
//! (windows registry key or qt .conf file). Smallest value that the GUI can
//! display is 1 GB, so round up if anything less is parsed.
static int ParsePruneSizeGB(const QVariant& prune_size)
{
return std::max(1, prune_size.toInt());
} }
struct ProxySetting { struct ProxySetting {
@ -375,10 +367,10 @@ static QString GetDefaultProxyAddress()
return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT); return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
} }
void OptionsModel::SetPruneTargetGB(int prune_target_gb) void OptionsModel::SetPruneTargetMiB(int prune_target_mib)
{ {
const common::SettingsValue cur_value = node().getPersistentSetting("prune"); const common::SettingsValue cur_value = node().getPersistentSetting("prune");
const common::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb); const common::SettingsValue new_value = PruneSettingFromMiB(prune_target_mib > 0, prune_target_mib);
// Force setting to take effect. It is still safe to change the value at // Force setting to take effect. It is still safe to change the value at
// this point because this function is only called after the intro screen is // this point because this function is only called after the intro screen is
@ -389,7 +381,7 @@ void OptionsModel::SetPruneTargetGB(int prune_target_gb)
// from saved value. Avoid writing settings.json if bitcoin.conf value // from saved value. Avoid writing settings.json if bitcoin.conf value
// doesn't need to be overridden. // doesn't need to be overridden.
if (PruneEnabled(cur_value) != PruneEnabled(new_value) || if (PruneEnabled(cur_value) != PruneEnabled(new_value) ||
PruneSizeGB(cur_value) != PruneSizeGB(new_value)) { PruneSizeAsMiB(cur_value) != PruneSizeAsMiB(new_value)) {
// Call UpdateRwSetting() instead of setOption() to avoid setting // Call UpdateRwSetting() instead of setOption() to avoid setting
// RestartRequired flag // RestartRequired flag
UpdateRwSetting(node(), Prune, "", new_value); UpdateRwSetting(node(), Prune, "", new_value);
@ -513,10 +505,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return settings.value("enable_psbt_controls"); return settings.value("enable_psbt_controls");
case Prune: case Prune:
return PruneEnabled(setting()); return PruneEnabled(setting());
case PruneSize: case PruneSizeMiB:
return PruneEnabled(setting()) ? PruneSizeGB(setting()) : return PruneEnabled(setting()) ? PruneSizeAsMiB(setting()) :
suffix.empty() ? getOption(option, "-prev") : suffix.empty() ? getOption(option, "-prev") :
DEFAULT_PRUNE_TARGET_GB; DEFAULT_PRUNE_TARGET_MiB;
case DatabaseCache: case DatabaseCache:
return qlonglong(SettingToInt(setting(), nDefaultDbCache)); return qlonglong(SettingToInt(setting(), nDefaultDbCache));
case ThreadsScriptVerif: case ThreadsScriptVerif:
@ -753,17 +745,17 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
case Prune: case Prune:
if (changed()) { if (changed()) {
if (suffix.empty() && !value.toBool()) setOption(option, true, "-prev"); if (suffix.empty() && !value.toBool()) setOption(option, true, "-prev");
update(PruneSetting(value.toBool(), getOption(PruneSize).toInt())); update(PruneSettingFromMiB(value.toBool(), getOption(PruneSizeMiB).toInt()));
if (suffix.empty() && value.toBool()) UpdateRwSetting(node(), option, "-prev", {}); if (suffix.empty() && value.toBool()) UpdateRwSetting(node(), option, "-prev", {});
if (suffix.empty()) setRestartRequired(true); if (suffix.empty()) setRestartRequired(true);
} }
break; break;
case PruneSize: case PruneSizeMiB:
if (changed()) { if (changed()) {
if (suffix.empty() && !getOption(Prune).toBool()) { if (suffix.empty() && !getOption(Prune).toBool()) {
setOption(option, value, "-prev"); setOption(option, value, "-prev");
} else { } else {
update(PruneSetting(true, ParsePruneSizeGB(value))); update(PruneSettingFromMiB(true, value.toInt()));
} }
if (suffix.empty() && getOption(Prune).toBool()) setRestartRequired(true); if (suffix.empty() && getOption(Prune).toBool()) setRestartRequired(true);
} }
@ -882,6 +874,11 @@ void OptionsModel::checkAndMigrate()
ProxySetting parsed = ParseProxyString(value.toString()); ProxySetting parsed = ParseProxyString(value.toString());
setOption(ProxyIPTor, parsed.ip); setOption(ProxyIPTor, parsed.ip);
setOption(ProxyPortTor, parsed.port); setOption(ProxyPortTor, parsed.port);
} else if (option == PruneSizeMiB) {
// Stored as GB
const int64_t prune_size_gb = value.toInt();
const int prune_size_mib = std::max(prune_size_gb * GB_BYTES / MiB_BYTES, MIN_DISK_SPACE_FOR_BLOCK_FILES / MiB_BYTES);
setOption(option, prune_size_mib);
} else { } else {
setOption(option, value); setOption(option, value);
} }
@ -899,7 +896,7 @@ void OptionsModel::checkAndMigrate()
migrate_setting(MapPortNatpmp, "fUseNatpmp"); migrate_setting(MapPortNatpmp, "fUseNatpmp");
migrate_setting(Listen, "fListen"); migrate_setting(Listen, "fListen");
migrate_setting(Server, "server"); migrate_setting(Server, "server");
migrate_setting(PruneSize, "nPruneSize"); migrate_setting(PruneSizeMiB, "nPruneSize");
migrate_setting(Prune, "bPrune"); migrate_setting(Prune, "bPrune");
migrate_setting(ProxyIP, "addrProxy"); migrate_setting(ProxyIP, "addrProxy");
migrate_setting(ProxyUse, "fUseProxy"); migrate_setting(ProxyUse, "fUseProxy");

View File

@ -23,16 +23,6 @@ class Node;
extern const char *DEFAULT_GUI_PROXY_HOST; extern const char *DEFAULT_GUI_PROXY_HOST;
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050; static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
/**
* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.
*/
static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES; }
/**
* Convert displayed prune target GB to configured MiB. Round down so roundtrip GB -> MiB -> GB conversion is stable.
*/
static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1024 / 1024; }
/** Interface from Qt to configuration data structure for Bitcoin client. /** Interface from Qt to configuration data structure for Bitcoin client.
To Qt, the options are presented as a list with the different options To Qt, the options are presented as a list with the different options
laid out vertically. laid out vertically.
@ -70,7 +60,7 @@ public:
SubFeeFromAmount, // bool SubFeeFromAmount, // bool
ThreadsScriptVerif, // int ThreadsScriptVerif, // int
Prune, // bool Prune, // bool
PruneSize, // int PruneSizeMiB, // int
DatabaseCache, // int DatabaseCache, // int
ExternalSignerPath, // QString ExternalSignerPath, // QString
SpendZeroConfChange, // bool SpendZeroConfChange, // bool
@ -121,7 +111,7 @@ public:
bool hasSigner(); bool hasSigner();
/* Explicit setters */ /* Explicit setters */
void SetPruneTargetGB(int prune_target_gb); void SetPruneTargetMiB(int prune_target_mib);
/* Restart flag helper */ /* Restart flag helper */
void setRestartRequired(bool fRequired); void setRestartRequired(bool fRequired);