Skip to content

Commit

Permalink
Merge #6368: fix(qt): set prune dependent options correctly
Browse files Browse the repository at this point in the history
2d99b2c fix: force correct `-disablegovernance` and `-txindex` values when pruning is requested via init dialog (UdjinM6)
64b20f0 fix(qt): set prune dependent options correctly (Kittywhiskers Van Gogh)

Pull request description:

  ## Issue being fixed or feature implemented
  A few things to note:
  1. we shouldn't rely on `bPrune` cause it can be overridden via cmd-line
  2. `addOverriddenOption` is used to highlight that there are GUI options that were overridden via cmd-line and neither `-disablegovernance` nor `-txindex` override anything, we simply set them to correct values here.
  3. we should do all that in `SetPruneEnabled` case that's the central point for GUI prune option logic

  fixes #6366

  #6367 alternative

  ## What was done?

  ## How Has This Been Tested?

  `./src/qt/dash-qt --regtest --resetguisettings` (could also add `--txindex=1` and/or `--disablegovernance=0`), check "Limit ..." box, click OK and confirm it continues with no errors (but with a warning about disabled governance, that's by design)

  close qt and check 2 more things:
  1. `./src/qt/dash-qt --regtest` should have a warning about disabled governance
  2. `./src/qt/dash-qt --regtest --prune=0` should have no warning about disabled governance (not true on `develop`)

  ## Breaking Changes

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  kwvg:
    ACK 2d99b2c
  PastaPastaPasta:
    utACK 2d99b2c

Tree-SHA512: 465bd2f1ca86358145c4671af554078b00b2472375d65b8de7e01ae0db8b24c9b01844a2b8e5a4c85a6d65a892a169ee61797591c0dfc0f51ec044a8e2bba58a
  • Loading branch information
PastaPastaPasta committed Oct 29, 2024
2 parents 79ced62 + 2d99b2c commit 93cfd5b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,6 @@ void OptionsModel::Init(bool resetSettings)
settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
SetPruneEnabled(settings.value("bPrune").toBool());

// If GUI is setting prune, then we also must set disablegovernance and txindex
if (settings.value("bPrune").toBool()) {
if (gArgs.SoftSetBoolArg("-disablegovernance", true)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -disablegovernance=true\n", __func__);
addOverriddenOption("-disablegovernance");
}
if (gArgs.SoftSetBoolArg("-txindex", false)) {
LogPrintf("%s: parameter interaction: -prune=true -> setting -txindex=false\n", __func__);
addOverriddenOption("-txindex");
}
}

if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
Expand Down Expand Up @@ -405,11 +393,19 @@ void OptionsModel::SetPruneEnabled(bool prune, bool force)
std::string prune_val = prune ? ToString(prune_target_mib) : "0";
if (force) {
gArgs.ForceSetArg("-prune", prune_val);
if (prune) {
gArgs.ForceSetArg("-disablegovernance", "1");
gArgs.ForceSetArg("-txindex", "0");
}
return;
}
if (!gArgs.SoftSetArg("-prune", prune_val)) {
addOverriddenOption("-prune");
}
if (gArgs.GetArg("-prune", 0) > 0) {
gArgs.SoftSetBoolArg("-disablegovernance", true);
gArgs.SoftSetBoolArg("-txindex", false);
}
}

void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force)
Expand Down

0 comments on commit 93cfd5b

Please sign in to comment.