Skip to content

Commit c8e2eee

Browse files
committed
chain: uniformly use SettingsAction enum in settings methods
1 parent 1e9e735 commit c8e2eee

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/interfaces/chain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,10 @@ class Chain
361361
virtual bool updateRwSetting(const std::string& name, const SettingsUpdate& update_function) = 0;
362362

363363
//! Replace a setting in <datadir>/settings.json with a new value.
364-
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, bool write = true) = 0;
364+
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, SettingsAction action = SettingsAction::WRITE) = 0;
365365

366366
//! Delete a given setting in <datadir>/settings.json.
367-
virtual bool deleteRwSettings(const std::string& name, bool write = true) = 0;
367+
virtual bool deleteRwSettings(const std::string& name, SettingsAction action = SettingsAction::WRITE) = 0;
368368

369369
//! Synchronously send transactionAddedToMempool notifications about all
370370
//! current mempool transactions to the specified handler and return after

src/node/interfaces.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,22 +826,22 @@ class ChainImpl : public Chain
826826
});
827827
if (!action) return false;
828828
// Now dump value to disk if requested
829-
return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
829+
return *action != interfaces::SettingsAction::WRITE || args().WriteSettingsFile();
830830
}
831-
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, bool write) override
831+
bool overwriteRwSetting(const std::string& name, common::SettingsValue value, interfaces::SettingsAction action) override
832832
{
833-
if (value.isNull()) return deleteRwSettings(name, write);
833+
if (value.isNull()) return deleteRwSettings(name, action);
834834
return updateRwSetting(name, [&](common::SettingsValue& settings) {
835835
settings = std::move(value);
836-
return write ? interfaces::SettingsAction::WRITE : interfaces::SettingsAction::SKIP_WRITE;
836+
return action;
837837
});
838838
}
839-
bool deleteRwSettings(const std::string& name, bool write) override
839+
bool deleteRwSettings(const std::string& name, interfaces::SettingsAction action) override
840840
{
841841
args().LockSettings([&](common::Settings& settings) {
842842
settings.rw_settings.erase(name);
843843
});
844-
return !write || args().WriteSettingsFile();
844+
return action != interfaces::SettingsAction::WRITE || args().WriteSettingsFile();
845845
}
846846
void requestMempoolTransactions(Notifications& notifications) override
847847
{

src/wallet/load.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool VerifyWallets(WalletContext& context)
6969
// Pass write=false because no need to write file and probably
7070
// better not to. If unnamed wallet needs to be added next startup
7171
// and the setting is empty, this code will just run again.
72-
chain.overwriteRwSetting("wallet", std::move(wallets), /*write=*/false);
72+
chain.overwriteRwSetting("wallet", std::move(wallets), interfaces::SettingsAction::SKIP_WRITE);
7373
}
7474
}
7575

0 commit comments

Comments
 (0)