Skip to content

Commit

Permalink
chain: move new settings safely in overwriteRwSetting
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Sep 5, 2024
1 parent 1c40900 commit 1e9e735
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ 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, bool write = true) = 0;

//! Delete a given setting in <datadir>/settings.json.
virtual bool deleteRwSettings(const std::string& name, bool write = true) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ class ChainImpl : public Chain
// Now dump value to disk if requested
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);
return updateRwSetting(name, [&](common::SettingsValue& settings) {
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", wallets, /*write=*/false);
chain.overwriteRwSetting("wallet", std::move(wallets), /*write=*/false);
}
}

Expand Down

0 comments on commit 1e9e735

Please sign in to comment.