mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
chain: move new settings safely in overwriteRwSetting
This commit is contained in:
parent
1c409004c8
commit
1e9e735670
3 changed files with 3 additions and 3 deletions
|
@ -361,7 +361,7 @@ public:
|
||||||
virtual bool updateRwSetting(const std::string& name, const SettingsUpdate& update_function) = 0;
|
virtual bool updateRwSetting(const std::string& name, const SettingsUpdate& update_function) = 0;
|
||||||
|
|
||||||
//! Replace a setting in <datadir>/settings.json with a new value.
|
//! Replace a setting in <datadir>/settings.json with a new value.
|
||||||
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue& value, bool write = true) = 0;
|
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, bool write = true) = 0;
|
||||||
|
|
||||||
//! Delete a given setting in <datadir>/settings.json.
|
//! Delete a given setting in <datadir>/settings.json.
|
||||||
virtual bool deleteRwSettings(const std::string& name, bool write = true) = 0;
|
virtual bool deleteRwSettings(const std::string& name, bool write = true) = 0;
|
||||||
|
|
|
@ -828,7 +828,7 @@ public:
|
||||||
// Now dump value to disk if requested
|
// Now dump value to disk if requested
|
||||||
return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
|
return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
|
||||||
}
|
}
|
||||||
bool overwriteRwSetting(const std::string& name, common::SettingsValue& value, bool write) override
|
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, bool write) override
|
||||||
{
|
{
|
||||||
if (value.isNull()) return deleteRwSettings(name, write);
|
if (value.isNull()) return deleteRwSettings(name, write);
|
||||||
return updateRwSetting(name, [&](common::SettingsValue& settings) {
|
return updateRwSetting(name, [&](common::SettingsValue& settings) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ bool VerifyWallets(WalletContext& context)
|
||||||
// Pass write=false because no need to write file and probably
|
// Pass write=false because no need to write file and probably
|
||||||
// better not to. If unnamed wallet needs to be added next startup
|
// better not to. If unnamed wallet needs to be added next startup
|
||||||
// and the setting is empty, this code will just run again.
|
// and the setting is empty, this code will just run again.
|
||||||
chain.overwriteRwSetting("wallet", wallets, /*write=*/false);
|
chain.overwriteRwSetting("wallet", std::move(wallets), /*write=*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue