mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
chain: uniformly use SettingsAction
enum in settings methods
This commit is contained in:
parent
1e9e735670
commit
c8e2eeeffb
3 changed files with 9 additions and 9 deletions
|
@ -361,10 +361,10 @@ public:
|
|||
virtual bool updateRwSetting(const std::string& name, const SettingsUpdate& update_function) = 0;
|
||||
|
||||
//! 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, SettingsAction action = SettingsAction::WRITE) = 0;
|
||||
|
||||
//! 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, SettingsAction action = SettingsAction::WRITE) = 0;
|
||||
|
||||
//! Synchronously send transactionAddedToMempool notifications about all
|
||||
//! current mempool transactions to the specified handler and return after
|
||||
|
|
|
@ -826,22 +826,22 @@ public:
|
|||
});
|
||||
if (!action) return false;
|
||||
// Now dump value to disk if requested
|
||||
return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
|
||||
return *action != interfaces::SettingsAction::WRITE || args().WriteSettingsFile();
|
||||
}
|
||||
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, bool write) override
|
||||
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, interfaces::SettingsAction action) override
|
||||
{
|
||||
if (value.isNull()) return deleteRwSettings(name, write);
|
||||
if (value.isNull()) return deleteRwSettings(name, action);
|
||||
return updateRwSetting(name, [&](common::SettingsValue& settings) {
|
||||
settings = std::move(value);
|
||||
return write ? interfaces::SettingsAction::WRITE : interfaces::SettingsAction::SKIP_WRITE;
|
||||
return action;
|
||||
});
|
||||
}
|
||||
bool deleteRwSettings(const std::string& name, bool write) override
|
||||
bool deleteRwSettings(const std::string& name, interfaces::SettingsAction action) override
|
||||
{
|
||||
args().LockSettings([&](common::Settings& settings) {
|
||||
settings.rw_settings.erase(name);
|
||||
});
|
||||
return !write || args().WriteSettingsFile();
|
||||
return action != interfaces::SettingsAction::WRITE || args().WriteSettingsFile();
|
||||
}
|
||||
void requestMempoolTransactions(Notifications& notifications) override
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ bool VerifyWallets(WalletContext& context)
|
|||
// Pass write=false because no need to write file and probably
|
||||
// better not to. If unnamed wallet needs to be added next startup
|
||||
// and the setting is empty, this code will just run again.
|
||||
chain.overwriteRwSetting("wallet", std::move(wallets), /*write=*/false);
|
||||
chain.overwriteRwSetting("wallet", std::move(wallets), interfaces::SettingsAction::SKIP_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue