scripted-diff: move settings to common namespace
-BEGIN VERIFY SCRIPT- sed -i 's/namespace\ util/namespace\ common/g' src/common/settings.cpp src/common/settings.h sed -i 's/util\:\:GetSetting/common\:\:GetSetting/g' $( git grep -l 'util\:\:GetSetting') sed -i 's/util\:\:Setting/common\:\:Setting/g' $( git grep -l 'util\:\:Setting') sed -i 's/util\:\:FindKey/common\:\:FindKey/g' $( git grep -l 'util\:\:FindKey') sed -i 's/util\:\:ReadSettings/common\:\:ReadSettings/g' $( git grep -l 'util\:\:ReadSettings') sed -i 's/util\:\:WriteSettings/common\:\:WriteSettings/g' $( git grep -l 'util\:\:WriteSettings') -END VERIFY SCRIPT-
This commit is contained in:
18 files changed
+120
-120
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");
|
||||
});
|
||||
|
||||
@@ -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