From 84663291275248fd52da644b0c2566bbf9cc780b Mon Sep 17 00:00:00 2001 From: ismaelsadeeq Date: Wed, 11 Sep 2024 16:57:28 +0100 Subject: [PATCH] chain: simplify `deleteRwSettings` code and improve it's doc Co-authored-by: Ryan Ofsky --- src/interfaces/chain.h | 2 ++ src/node/interfaces.cpp | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index e81d1888ac4..7bc2d11b607 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -369,6 +369,8 @@ public: virtual bool overwriteRwSetting(const std::string& name, common::SettingsValue value, SettingsAction action = SettingsAction::WRITE) = 0; //! Delete a given setting in /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 diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index f6d85f2b72a..31536e15d0d 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -841,10 +841,7 @@ public: } 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 {