Merge bitcoin/bitcoin#22217: refactor: Avoid wallet code writing node settings file

49ee2a0ad8 Avoid wallet code writing node settings file (Russell Yanofsky)

Pull request description:

  Change wallet loading code to access settings through the Chain interface instead of writing settings.json directly. This is for running wallet and node in separate processes, since multiprocess code wouldn't easily work with different processes updating the same file.

  ---

  This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR #10102.

ACKs for top commit:
  jamesob:
    ACK 49ee2a0ad8 ([`jamesob/ackr/22217.1.ryanofsky.refactor_avoid_wallet_co`](https://github.com/jamesob/bitcoin/tree/ackr/22217.1.ryanofsky.refactor_avoid_wallet_co))
  ryanofsky:
    > ACK [49ee2a0](49ee2a0ad8) ([`jamesob/ackr/22217.1.ryanofsky.refactor_avoid_wallet_co`](https://github.com/jamesob/bitcoin/tree/ackr/22217.1.ryanofsky.refactor_avoid_wallet_co))
  Zero-1729:
    crACK 49ee2a0ad8
  meshcollider:
    Code review ACK 49ee2a0ad8

Tree-SHA512: a81c63b87816f739e02e3992808f314294d6c7213babaafdaaf3c4650ebc97ee4f98f9a4684ce4ff87372df59989b8ad5929159c5686293a7cce04e97e2fabba
This commit is contained in:
Samuel Dobson
2021-08-19 10:03:18 +12:00
4 changed files with 30 additions and 12 deletions

View File

@@ -661,6 +661,14 @@ public:
RPCRunLater(name, std::move(fn), seconds);
}
int rpcSerializationFlags() override { return RPCSerializationFlags(); }
util::SettingsValue getSetting(const std::string& name) override
{
return gArgs.GetSetting(name);
}
std::vector<util::SettingsValue> getSettingsList(const std::string& name) override
{
return gArgs.GetSettingsList(name);
}
util::SettingsValue getRwSetting(const std::string& name) override
{
util::SettingsValue result;
@@ -671,7 +679,7 @@ public:
});
return result;
}
bool updateRwSetting(const std::string& name, const util::SettingsValue& value) override
bool updateRwSetting(const std::string& name, const util::SettingsValue& value, bool write) override
{
gArgs.LockSettings([&](util::Settings& settings) {
if (value.isNull()) {
@@ -680,7 +688,7 @@ public:
settings.rw_settings[name] = value;
}
});
return gArgs.WriteSettingsFile();
return !write || gArgs.WriteSettingsFile();
}
void requestMempoolTransactions(Notifications& notifications) override
{