Merge bitcoin/bitcoin#27576: kernel: Remove args, settings, chainparams, chainparamsbase from kernel library
db77f87c63scripted-diff: move settings to common namespace (TheCharlatan)c27e4bdc35move-only: Move settings to the common library (TheCharlatan)c2dae5d7d8kernel: Remove chainparams, chainparamsbase, args, settings from kernel library (TheCharlatan)05870b1c92refactor: Remove gArgs access from validation.cpp (TheCharlatan)8789b11114refactor: Add path argument to FindSnapshotChainstateDir (TheCharlatan)ef95be334frefactor: Add stop_at_height option in ChainstateManager (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/27587 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". --- This completes the removal of the node's chainparams, chainparamsbase, args and settings files and their respective classes from the kernel library. This is the last pull request in a long series working towards decoupling the `ArgsManager` and the `gArgs` global from kernel code. These prior pull requests are: https://github.com/bitcoin/bitcoin/pull/26177 https://github.com/bitcoin/bitcoin/pull/27125 https://github.com/bitcoin/bitcoin/pull/25527 https://github.com/bitcoin/bitcoin/pull/25487 https://github.com/bitcoin/bitcoin/pull/25290 ACKs for top commit: MarcoFalke: lgtm ACKdb77f87c63🍄 hebasto: ACKdb77f87c63, I have reviewed the code and it looks OK. ryanofsky: Code review ACKdb77f87c63. Looks great! Tree-SHA512: cbfbd705d056f2f10f16810d4f869eb152362fff2c5ddae5e1ac6785deae095588e52ad48b29d921962b085e51de1e0ecab6e50f46149ffe3c16250608a2c93a
This commit is contained in:
27 files changed
+167
-171
No files matched your search
@@ -60,7 +60,7 @@ static const char* SettingName(OptionsModel::OptionID option)
|
||||
}
|
||||
|
||||
/** Call node.updateRwSetting() with Bitcoin 22.x workaround. */
|
||||
static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID option, const std::string& suffix, const util::SettingsValue& value)
|
||||
static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID option, const std::string& suffix, const common::SettingsValue& value)
|
||||
{
|
||||
if (value.isNum() &&
|
||||
(option == OptionsModel::DatabaseCache ||
|
||||
@@ -81,14 +81,14 @@ static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID optio
|
||||
}
|
||||
|
||||
//! Convert enabled/size values to bitcoin -prune setting.
|
||||
static util::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
|
||||
static common::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
|
||||
{
|
||||
assert(!prune_enabled || prune_size_gb >= 1); // PruneSizeGB and ParsePruneSizeGB never return less
|
||||
return prune_enabled ? PruneGBtoMiB(prune_size_gb) : 0;
|
||||
}
|
||||
|
||||
//! Get pruning enabled value to show in GUI from bitcoin -prune setting.
|
||||
static bool PruneEnabled(const util::SettingsValue& prune_setting)
|
||||
static bool PruneEnabled(const common::SettingsValue& prune_setting)
|
||||
{
|
||||
// -prune=1 setting is manual pruning mode, so disabled for purposes of the gui
|
||||
return SettingToInt(prune_setting, 0) > 1;
|
||||
@@ -96,7 +96,7 @@ static bool PruneEnabled(const util::SettingsValue& prune_setting)
|
||||
|
||||
//! Get pruning size value to show in GUI from bitcoin -prune setting. If
|
||||
//! pruning is not enabled, just show default recommended pruning size (2GB).
|
||||
static int PruneSizeGB(const util::SettingsValue& prune_setting)
|
||||
static int PruneSizeGB(const common::SettingsValue& prune_setting)
|
||||
{
|
||||
int value = SettingToInt(prune_setting, 0);
|
||||
return value > 1 ? PruneMiBtoGB(value) : DEFAULT_PRUNE_TARGET_GB;
|
||||
@@ -311,8 +311,8 @@ static QString GetDefaultProxyAddress()
|
||||
|
||||
void OptionsModel::SetPruneTargetGB(int prune_target_gb)
|
||||
{
|
||||
const util::SettingsValue cur_value = node().getPersistentSetting("prune");
|
||||
const util::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb);
|
||||
const common::SettingsValue cur_value = node().getPersistentSetting("prune");
|
||||
const common::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb);
|
||||
|
||||
// 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
|
||||
@@ -331,7 +331,7 @@ void OptionsModel::SetPruneTargetGB(int prune_target_gb)
|
||||
|
||||
// Keep previous pruning size, if pruning was disabled.
|
||||
if (PruneEnabled(cur_value)) {
|
||||
UpdateRwSetting(node(), Prune, "-prev", PruneEnabled(new_value) ? util::SettingsValue{} : cur_value);
|
||||
UpdateRwSetting(node(), Prune, "-prev", PruneEnabled(new_value) ? common::SettingsValue{} : cur_value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
|
||||
bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::string& suffix)
|
||||
{
|
||||
auto changed = [&] { return value.isValid() && value != getOption(option, suffix); };
|
||||
auto update = [&](const util::SettingsValue& value) { return UpdateRwSetting(node(), option, suffix, value); };
|
||||
auto update = [&](const common::SettingsValue& value) { return UpdateRwSetting(node(), option, suffix, value); };
|
||||
|
||||
bool successful = true; /* set to false on parse error */
|
||||
QSettings settings;
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
|
||||
OptionTests::OptionTests(interfaces::Node& node) : m_node(node)
|
||||
{
|
||||
gArgs.LockSettings([&](util::Settings& s) { m_previous_settings = s; });
|
||||
gArgs.LockSettings([&](common::Settings& s) { m_previous_settings = s; });
|
||||
}
|
||||
|
||||
void OptionTests::init()
|
||||
{
|
||||
// reset args
|
||||
gArgs.LockSettings([&](util::Settings& s) { s = m_previous_settings; });
|
||||
gArgs.LockSettings([&](common::Settings& s) { s = m_previous_settings; });
|
||||
gArgs.ClearPathCache();
|
||||
}
|
||||
|
||||
@@ -76,14 +76,14 @@ void OptionTests::integerGetArgBug()
|
||||
// Test regression https://github.com/bitcoin/bitcoin/issues/24457. Ensure
|
||||
// that setting integer prune value doesn't cause an exception to be thrown
|
||||
// in the OptionsModel constructor
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
gArgs.LockSettings([&](common::Settings& settings) {
|
||||
settings.forced_settings.erase("prune");
|
||||
settings.rw_settings["prune"] = 3814;
|
||||
});
|
||||
gArgs.WriteSettingsFile();
|
||||
bilingual_str error;
|
||||
QVERIFY(OptionsModel{m_node}.Init(error));
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
gArgs.LockSettings([&](common::Settings& settings) {
|
||||
settings.rw_settings.erase("prune");
|
||||
});
|
||||
gArgs.WriteSettingsFile();
|
||||
@@ -95,7 +95,7 @@ void OptionTests::parametersInteraction()
|
||||
// It was fixed via https://github.com/bitcoin-core/gui/pull/568.
|
||||
// With fListen=false in ~/.config/Bitcoin/Bitcoin-Qt.conf and all else left as default,
|
||||
// bitcoin-qt should set both -listen and -listenonion to false and start successfully.
|
||||
gArgs.LockSettings([&](util::Settings& s) {
|
||||
gArgs.LockSettings([&](common::Settings& s) {
|
||||
s.forced_settings.erase("listen");
|
||||
s.forced_settings.erase("listenonion");
|
||||
});
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#ifndef BITCOIN_QT_TEST_OPTIONTESTS_H
|
||||
#define BITCOIN_QT_TEST_OPTIONTESTS_H
|
||||
|
||||
#include <common/settings.h>
|
||||
#include <qt/optionsmodel.h>
|
||||
#include <univalue.h>
|
||||
#include <util/settings.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -26,7 +26,7 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
interfaces::Node& m_node;
|
||||
util::Settings m_previous_settings;
|
||||
common::Settings m_previous_settings;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_TEST_OPTIONTESTS_H
|
||||
Reference in new issue
Block a user