mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-15 03:12:44 +02:00
Merge #17696: qt: Force set nPruneSize in QSettings after the intro dialog
af112ab62895b145660f4cd7ff842e9cfea2a530 qt: Rename SetPrune() to InitializePruneSetting() (Hennadii Stepanov) b0bfbe50282877a1eee87118902901a280d6656d refactor: Drop `bool force' parameter (Hennadii Stepanov) 68c9bbe9bc91f882404556998666b1b5acea60e4 qt: Force set nPruneSize in QSettings after intro (Hennadii Stepanov) a82bd8fa5708c16d1db3edc4e82d70788eb5af19 util: Replace magics with DEFAULT_PRUNE_TARGET_GB (Hennadii Stepanov) Pull request description: On master (5622d8f3156a293e61d0964c33d4b21d8c9fd5e0), having `QSettings` set already ``` $ grep nPruneSize ~/.config/Bitcoin/Bitcoin-Qt-testnet.conf nPruneSize=6 ``` enabling prune option in the intro dialog ``` $ ./src/qt/bitcoin-qt -choosedatadir -testnet ```  has no effect: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:04:41Z Prune configured to target 5722 MiB on disk for block and undo files. ``` --- With this PR: ``` $ grep Prune ~/.bitcoin/testnet3/debug.log 2019-12-08T10:20:35Z Prune configured to target 1907 MiB on disk for block and undo files. ``` This PR has been split of #17453 (the first two commits) as it fixes an orthogonal bug. Refs: - https://github.com/bitcoin/bitcoin/pull/17453#discussion_r345424240 - https://github.com/bitcoin/bitcoin/pull/17453#discussion_r350960201 ACKs for top commit: Sjors: Code review re-ACK af112ab62895b145660f4cd7ff842e9cfea2a530 ryanofsky: Code review ACK af112ab62895b145660f4cd7ff842e9cfea2a530. Just suggested changes since last review (thanks!) promag: Tested ACK af112ab62895b145660f4cd7ff842e9cfea2a530. Latest suggestions and changes look good to me. Tree-SHA512: 8ddad34b30dcc2cdcad6678ba8a0b36fa176e4e3465862ef6eee9be0f98d8146705138c9c7995dd8c0990af41078ca743fef1a90ed9240081f052f32ddec72b9
This commit is contained in:
commit
7f3675b3ce
@ -281,8 +281,11 @@ void BitcoinApplication::parameterSetup()
|
|||||||
m_node.initParameterInteraction();
|
m_node.initParameterInteraction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::SetPrune(bool prune, bool force) {
|
void BitcoinApplication::InitializePruneSetting(bool prune)
|
||||||
optionsModel->SetPrune(prune, force);
|
{
|
||||||
|
// If prune is set, intentionally override existing prune size with
|
||||||
|
// the default size since this is called when choosing a new datadir.
|
||||||
|
optionsModel->SetPruneTargetGB(prune ? DEFAULT_PRUNE_TARGET_GB : 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinApplication::requestInitialize()
|
void BitcoinApplication::requestInitialize()
|
||||||
@ -562,7 +565,7 @@ int GuiMain(int argc, char* argv[])
|
|||||||
|
|
||||||
if (did_show_intro) {
|
if (did_show_intro) {
|
||||||
// Store intro dialog settings other than datadir (network specific)
|
// Store intro dialog settings other than datadir (network specific)
|
||||||
app.SetPrune(prune, true);
|
app.InitializePruneSetting(prune);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
|
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
|
||||||
|
@ -67,8 +67,8 @@ public:
|
|||||||
void parameterSetup();
|
void parameterSetup();
|
||||||
/// Create options model
|
/// Create options model
|
||||||
void createOptionsModel(bool resetSettings);
|
void createOptionsModel(bool resetSettings);
|
||||||
/// Update prune value
|
/// Initialize prune setting
|
||||||
void SetPrune(bool prune, bool force = false);
|
void InitializePruneSetting(bool prune);
|
||||||
/// Create main window
|
/// Create main window
|
||||||
void createWindow(const NetworkStyle *networkStyle);
|
void createWindow(const NetworkStyle *networkStyle);
|
||||||
/// Create splash screen
|
/// Create splash screen
|
||||||
|
@ -51,4 +51,7 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
|
|||||||
/* 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.
|
||||||
|
static constexpr int DEFAULT_PRUNE_TARGET_GB{2};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_GUICONSTANTS_H
|
#endif // BITCOIN_QT_GUICONSTANTS_H
|
||||||
|
@ -135,7 +135,7 @@ Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_siz
|
|||||||
ui->prune->setChecked(true);
|
ui->prune->setChecked(true);
|
||||||
ui->prune->setEnabled(false);
|
ui->prune->setEnabled(false);
|
||||||
}
|
}
|
||||||
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(pruneTarget ? pruneTarget / 1000 : 2));
|
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(pruneTarget ? pruneTarget / 1000 : DEFAULT_PRUNE_TARGET_GB));
|
||||||
requiredSpace = m_blockchain_size;
|
requiredSpace = m_blockchain_size;
|
||||||
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 (pruneTarget) {
|
if (pruneTarget) {
|
||||||
|
@ -91,8 +91,8 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
if (!settings.contains("bPrune"))
|
if (!settings.contains("bPrune"))
|
||||||
settings.setValue("bPrune", false);
|
settings.setValue("bPrune", false);
|
||||||
if (!settings.contains("nPruneSize"))
|
if (!settings.contains("nPruneSize"))
|
||||||
settings.setValue("nPruneSize", 2);
|
settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
|
||||||
SetPrune(settings.value("bPrune").toBool());
|
SetPruneEnabled(settings.value("bPrune").toBool());
|
||||||
|
|
||||||
if (!settings.contains("nDatabaseCache"))
|
if (!settings.contains("nDatabaseCache"))
|
||||||
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
||||||
@ -236,7 +236,7 @@ static const 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::SetPrune(bool prune, bool force)
|
void OptionsModel::SetPruneEnabled(bool prune, bool force)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("bPrune", prune);
|
settings.setValue("bPrune", prune);
|
||||||
@ -252,6 +252,16 @@ void OptionsModel::SetPrune(bool prune, bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force)
|
||||||
|
{
|
||||||
|
const bool prune = prune_target_gb > 0;
|
||||||
|
if (prune) {
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue("nPruneSize", prune_target_gb);
|
||||||
|
}
|
||||||
|
SetPruneEnabled(prune, force);
|
||||||
|
}
|
||||||
|
|
||||||
// read QSettings values and return them
|
// read QSettings values and return them
|
||||||
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,8 @@ public:
|
|||||||
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
||||||
|
|
||||||
/* Explicit setters */
|
/* Explicit setters */
|
||||||
void SetPrune(bool prune, bool force = false);
|
void SetPruneEnabled(bool prune, bool force = false);
|
||||||
|
void SetPruneTargetGB(int prune_target_gb, bool force = false);
|
||||||
|
|
||||||
/* Restart flag helper */
|
/* Restart flag helper */
|
||||||
void setRestartRequired(bool fRequired);
|
void setRestartRequired(bool fRequired);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user