Skip to content

Commit

Permalink
chain: simplify deleteRwSettings code and improve it's doc
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
  • Loading branch information
ismaelsadeeq and ryanofsky committed Sep 11, 2024
1 parent f8d91f4 commit 8466329
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ class Chain
virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, SettingsAction action = SettingsAction::WRITE) = 0;

//! Delete a given setting in <datadir>/settings.json.
//! This method provides a simpler alternative to overwriteRwSetting when
//! erasing a setting, for ease of use and readability.
virtual bool deleteRwSettings(const std::string& name, SettingsAction action = SettingsAction::WRITE) = 0;

//! Synchronously send transactionAddedToMempool notifications about all
Expand Down
5 changes: 1 addition & 4 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,10 +841,7 @@ class ChainImpl : public Chain
}
bool deleteRwSettings(const std::string& name, interfaces::SettingsAction action) override
{
args().LockSettings([&](common::Settings& settings) {
settings.rw_settings.erase(name);
});
return action != interfaces::SettingsAction::WRITE || args().WriteSettingsFile();
return overwriteRwSetting(name, {}, action);
}
void requestMempoolTransactions(Notifications& notifications) override
{
Expand Down

0 comments on commit 8466329

Please sign in to comment.