Merge bitcoin/bitcoin#15936: interfaces: Expose settings.json methods to GUI

f9fdcec7e9 settings: Add resetSettings() method (Ryan Ofsky)
77fabffef4 init: Remove Shutdown() node.args reset (Ryan Ofsky)
0e55bc6e7f settings: 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:
    ACK f9fdcec7e9
  hebasto:
    re-ACK f9fdcec7e9, 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:
MacroFake
2022-05-26 17:05:01 +02:00
8 changed files with 123 additions and 17 deletions

View File

@@ -160,6 +160,10 @@ struct SectionInfo
int m_line;
};
std::string SettingToString(const util::SettingsValue&, const std::string&);
int64_t SettingToInt(const util::SettingsValue&, int64_t);
bool SettingToBool(const util::SettingsValue&, bool);
class ArgsManager
{
public:
@@ -436,7 +440,7 @@ protected:
* Get settings file path, or return false if read-write settings were
* disabled with -nosettings.
*/
bool GetSettingsPath(fs::path* filepath = nullptr, bool temp = false) const;
bool GetSettingsPath(fs::path* filepath = nullptr, bool temp = false, bool backup = false) const;
/**
* Read settings file. Push errors to vector, or log them if null.
@@ -444,9 +448,16 @@ protected:
bool ReadSettingsFile(std::vector<std::string>* errors = nullptr);
/**
* Write settings file. Push errors to vector, or log them if null.
* Write settings file or backup settings file. Push errors to vector, or
* log them if null.
*/
bool WriteSettingsFile(std::vector<std::string>* errors = nullptr) const;
bool WriteSettingsFile(std::vector<std::string>* errors = nullptr, bool backup = false) const;
/**
* Get current setting from config file or read/write settings file,
* ignoring nonpersistent command line or forced settings values.
*/
util::SettingsValue GetPersistentSetting(const std::string& name) const;
/**
* Access settings with lock held.