Skip to content

Commit

Permalink
chain: uniformly use SettingsAction enum in all settings methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Sep 8, 2024
1 parent 1e9e735 commit 96bd614
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ class Chain
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
Expand Down
12 changes: 6 additions & 6 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,22 +826,22 @@ class ChainImpl : public Chain
});
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
{
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 96bd614

Please sign in to comment.