mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
Merge bitcoin/bitcoin#15936: interfaces: Expose settings.json methods to GUI
f9fdcec7e9settings: Add resetSettings() method (Ryan Ofsky)77fabffef4init: Remove Shutdown() node.args reset (Ryan Ofsky)0e55bc6e7fsettings: Add update/getPersistent/isIgnored methods (Ryan Ofsky) Pull request description: Add `interfaces::Node` `updateSetting`, `forceSetting`, `resetSettings`, `isSettingIgnored`, and `getPersistentSetting` methods so GUI is able to manipulate `settings.json` file and use and modify node settings. (Originally this PR also contained GUI changes to unify bitcoin-qt and bitcoind persistent settings and call these methods, but the GUI commits have been dropped from this PR and moved to bitcoin-core/gui/pull/602) ACKs for top commit: vasild: ACKf9fdcec7e9hebasto: re-ACKf9fdcec7e9, only a function renamed since my recent [review](https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-979324357). Tree-SHA512: 4cac853ee29be96d2ff38404165b9dfb7c622b2a9c99a15979596f3484ffde0da3d9c9c372677dff5119ca7cffa6383d81037fd9889a29cc9285882a8dc0c268
This commit is contained in:
@@ -112,6 +112,46 @@ public:
|
||||
}
|
||||
}
|
||||
bool shutdownRequested() override { return ShutdownRequested(); }
|
||||
bool isSettingIgnored(const std::string& name) override
|
||||
{
|
||||
bool ignored = false;
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
if (auto* options = util::FindKey(settings.command_line_options, name)) {
|
||||
ignored = !options->empty();
|
||||
}
|
||||
});
|
||||
return ignored;
|
||||
}
|
||||
util::SettingsValue getPersistentSetting(const std::string& name) override { return gArgs.GetPersistentSetting(name); }
|
||||
void updateRwSetting(const std::string& name, const util::SettingsValue& value) override
|
||||
{
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.rw_settings.erase(name);
|
||||
} else {
|
||||
settings.rw_settings[name] = value;
|
||||
}
|
||||
});
|
||||
gArgs.WriteSettingsFile();
|
||||
}
|
||||
void forceSetting(const std::string& name, const util::SettingsValue& value) override
|
||||
{
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.forced_settings.erase(name);
|
||||
} else {
|
||||
settings.forced_settings[name] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
void resetSettings() override
|
||||
{
|
||||
gArgs.WriteSettingsFile(/*errors=*/nullptr, /*backup=*/true);
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
settings.rw_settings.clear();
|
||||
});
|
||||
gArgs.WriteSettingsFile();
|
||||
}
|
||||
void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); }
|
||||
bool getProxy(Network net, Proxy& proxy_info) override { return GetProxy(net, proxy_info); }
|
||||
size_t getNodeCount(ConnectionDirection flags) override
|
||||
|
||||
Reference in New Issue
Block a user