mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 78567b052d into merged_master (Bitcoin PR bitcoin/bitcoin#30697)
This commit is contained in:
commit
fc0ac93eb7
5 changed files with 100 additions and 25 deletions
|
|
@ -815,14 +815,32 @@ public:
|
|||
});
|
||||
return result;
|
||||
}
|
||||
bool updateRwSetting(const std::string& name, const common::SettingsValue& value, bool write) override
|
||||
bool updateRwSetting(const std::string& name,
|
||||
const interfaces::SettingsUpdate& update_settings_func) override
|
||||
{
|
||||
std::optional<interfaces::SettingsAction> action;
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
auto* ptr_value = common::FindKey(settings.rw_settings, name);
|
||||
// Create value if it doesn't exist
|
||||
auto& value = ptr_value ? *ptr_value : settings.rw_settings[name];
|
||||
action = update_settings_func(value);
|
||||
});
|
||||
if (!action) return false;
|
||||
// Now dump value to disk if requested
|
||||
return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
|
||||
}
|
||||
bool overwriteRwSetting(const std::string& name, common::SettingsValue& value, bool write) override
|
||||
{
|
||||
if (value.isNull()) return deleteRwSettings(name, write);
|
||||
return updateRwSetting(name, [&](common::SettingsValue& settings) {
|
||||
settings = std::move(value);
|
||||
return write ? interfaces::SettingsAction::WRITE : interfaces::SettingsAction::SKIP_WRITE;
|
||||
});
|
||||
}
|
||||
bool deleteRwSettings(const std::string& name, bool write) override
|
||||
{
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.rw_settings.erase(name);
|
||||
} else {
|
||||
settings.rw_settings[name] = value;
|
||||
}
|
||||
settings.rw_settings.erase(name);
|
||||
});
|
||||
return !write || args().WriteSettingsFile();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue