scripted-diff: move settings to common namespace

-BEGIN VERIFY SCRIPT-
sed -i 's/namespace\ util/namespace\ common/g' src/common/settings.cpp src/common/settings.h
sed -i 's/util\:\:GetSetting/common\:\:GetSetting/g' $( git grep -l 'util\:\:GetSetting')
sed -i 's/util\:\:Setting/common\:\:Setting/g' $( git grep -l 'util\:\:Setting')
sed -i 's/util\:\:FindKey/common\:\:FindKey/g' $( git grep -l 'util\:\:FindKey')
sed -i 's/util\:\:ReadSettings/common\:\:ReadSettings/g' $( git grep -l 'util\:\:ReadSettings')
sed -i 's/util\:\:WriteSettings/common\:\:WriteSettings/g' $( git grep -l 'util\:\:WriteSettings')
-END VERIFY SCRIPT-
This commit is contained in:
TheCharlatan committed 2023-05-30 17:26:51 +02:00
1 parent c27e4bdc35
commit db77f87c63
18 files changed
+120 -120

No files matched your search

+3 -3
View File
@@ -132,7 +132,7 @@ CBanDB::CBanDB(fs::path ban_list_path)
bool CBanDB::Write(const banmap_t& banSet) bool CBanDB::Write(const banmap_t& banSet)
{ {
std::vector<std::string> errors; std::vector<std::string> errors;
if (util::WriteSettings(m_banlist_json, {{JSON_KEY, BanMapToJson(banSet)}}, errors)) { if (common::WriteSettings(m_banlist_json, {{JSON_KEY, BanMapToJson(banSet)}}, errors)) {
return true; return true;
} }
@@ -152,10 +152,10 @@ bool CBanDB::Read(banmap_t& banSet)
return false; return false;
} }
std::map<std::string, util::SettingsValue> settings; std::map<std::string, common::SettingsValue> settings;
std::vector<std::string> errors; std::vector<std::string> errors;
if (!util::ReadSettings(m_banlist_json, settings, errors)) { if (!common::ReadSettings(m_banlist_json, settings, errors)) {
for (const auto& err : errors) { for (const auto& err : errors) {
LogPrintf("Cannot load banlist %s: %s\n", fs::PathToString(m_banlist_json), err); LogPrintf("Cannot load banlist %s: %s\n", fs::PathToString(m_banlist_json), err);
} }
+24 -24
View File
@@ -104,7 +104,7 @@ KeyInfo InterpretKey(std::string key)
* @return parsed settings value if it is valid, otherwise nullopt accompanied * @return parsed settings value if it is valid, otherwise nullopt accompanied
* by a descriptive error string * by a descriptive error string
*/ */
std::optional<util::SettingsValue> InterpretValue(const KeyInfo& key, const std::string* value, std::optional<common::SettingsValue> InterpretValue(const KeyInfo& key, const std::string* value,
unsigned int flags, std::string& error) unsigned int flags, std::string& error)
{ {
// Return negated settings as false values. // Return negated settings as false values.
@@ -238,15 +238,15 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
return false; return false;
} }
std::optional<util::SettingsValue> value = InterpretValue(keyinfo, val ? &*val : nullptr, *flags, error); std::optional<common::SettingsValue> value = InterpretValue(keyinfo, val ? &*val : nullptr, *flags, error);
if (!value) return false; if (!value) return false;
m_settings.command_line_options[keyinfo.name].push_back(*value); m_settings.command_line_options[keyinfo.name].push_back(*value);
} }
// we do not allow -includeconf from command line, only -noincludeconf // we do not allow -includeconf from command line, only -noincludeconf
if (auto* includes = util::FindKey(m_settings.command_line_options, "includeconf")) { if (auto* includes = common::FindKey(m_settings.command_line_options, "includeconf")) {
const util::SettingsSpan values{*includes}; const common::SettingsSpan values{*includes};
// Range may be empty if -noincludeconf was passed // Range may be empty if -noincludeconf was passed
if (!values.empty()) { if (!values.empty()) {
error = "-includeconf cannot be used from commandline; -includeconf=" + values.begin()->write(); error = "-includeconf cannot be used from commandline; -includeconf=" + values.begin()->write();
@@ -361,7 +361,7 @@ std::optional<const ArgsManager::Command> ArgsManager::GetCommand() const
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const
{ {
std::vector<std::string> result; std::vector<std::string> result;
for (const util::SettingsValue& value : GetSettingsList(strArg)) { for (const common::SettingsValue& value : GetSettingsList(strArg)) {
result.push_back(value.isFalse() ? "0" : value.isTrue() ? "1" : value.get_str()); result.push_back(value.isFalse() ? "0" : value.isTrue() ? "1" : value.get_str());
} }
return result; return result;
@@ -408,7 +408,7 @@ bool ArgsManager::ReadSettingsFile(std::vector<std::string>* errors)
LOCK(cs_args); LOCK(cs_args);
m_settings.rw_settings.clear(); m_settings.rw_settings.clear();
std::vector<std::string> read_errors; std::vector<std::string> read_errors;
if (!util::ReadSettings(path, m_settings.rw_settings, read_errors)) { if (!common::ReadSettings(path, m_settings.rw_settings, read_errors)) {
SaveErrors(read_errors, errors); SaveErrors(read_errors, errors);
return false; return false;
} }
@@ -430,7 +430,7 @@ bool ArgsManager::WriteSettingsFile(std::vector<std::string>* errors, bool backu
LOCK(cs_args); LOCK(cs_args);
std::vector<std::string> write_errors; std::vector<std::string> write_errors;
if (!util::WriteSettings(path_tmp, m_settings.rw_settings, write_errors)) { if (!common::WriteSettings(path_tmp, m_settings.rw_settings, write_errors)) {
SaveErrors(write_errors, errors); SaveErrors(write_errors, errors);
return false; return false;
} }
@@ -441,10 +441,10 @@ bool ArgsManager::WriteSettingsFile(std::vector<std::string>* errors, bool backu
return true; return true;
} }
util::SettingsValue ArgsManager::GetPersistentSetting(const std::string& name) const common::SettingsValue ArgsManager::GetPersistentSetting(const std::string& name) const
{ {
LOCK(cs_args); LOCK(cs_args);
return util::GetSetting(m_settings, m_network, name, !UseDefaultSection("-" + name), return common::GetSetting(m_settings, m_network, name, !UseDefaultSection("-" + name),
/*ignore_nonpersistent=*/true, /*get_chain_type=*/false); /*ignore_nonpersistent=*/true, /*get_chain_type=*/false);
} }
@@ -460,11 +460,11 @@ std::string ArgsManager::GetArg(const std::string& strArg, const std::string& st
std::optional<std::string> ArgsManager::GetArg(const std::string& strArg) const std::optional<std::string> ArgsManager::GetArg(const std::string& strArg) const
{ {
const util::SettingsValue value = GetSetting(strArg); const common::SettingsValue value = GetSetting(strArg);
return SettingToString(value); return SettingToString(value);
} }
std::optional<std::string> SettingToString(const util::SettingsValue& value) std::optional<std::string> SettingToString(const common::SettingsValue& value)
{ {
if (value.isNull()) return std::nullopt; if (value.isNull()) return std::nullopt;
if (value.isFalse()) return "0"; if (value.isFalse()) return "0";
@@ -473,7 +473,7 @@ std::optional<std::string> SettingToString(const util::SettingsValue& value)
return value.get_str(); return value.get_str();
} }
std::string SettingToString(const util::SettingsValue& value, const std::string& strDefault) std::string SettingToString(const common::SettingsValue& value, const std::string& strDefault)
{ {
return SettingToString(value).value_or(strDefault); return SettingToString(value).value_or(strDefault);
} }
@@ -485,11 +485,11 @@ int64_t ArgsManager::GetIntArg(const std::string& strArg, int64_t nDefault) cons
std::optional<int64_t> ArgsManager::GetIntArg(const std::string& strArg) const std::optional<int64_t> ArgsManager::GetIntArg(const std::string& strArg) const
{ {
const util::SettingsValue value = GetSetting(strArg); const common::SettingsValue value = GetSetting(strArg);
return SettingToInt(value); return SettingToInt(value);
} }
std::optional<int64_t> SettingToInt(const util::SettingsValue& value) std::optional<int64_t> SettingToInt(const common::SettingsValue& value)
{ {
if (value.isNull()) return std::nullopt; if (value.isNull()) return std::nullopt;
if (value.isFalse()) return 0; if (value.isFalse()) return 0;
@@ -498,7 +498,7 @@ std::optional<int64_t> SettingToInt(const util::SettingsValue& value)
return LocaleIndependentAtoi<int64_t>(value.get_str()); return LocaleIndependentAtoi<int64_t>(value.get_str());
} }
int64_t SettingToInt(const util::SettingsValue& value, int64_t nDefault) int64_t SettingToInt(const common::SettingsValue& value, int64_t nDefault)
{ {
return SettingToInt(value).value_or(nDefault); return SettingToInt(value).value_or(nDefault);
} }
@@ -510,18 +510,18 @@ bool ArgsManager::GetBoolArg(const std::string& strArg, bool fDefault) const
std::optional<bool> ArgsManager::GetBoolArg(const std::string& strArg) const std::optional<bool> ArgsManager::GetBoolArg(const std::string& strArg) const
{ {
const util::SettingsValue value = GetSetting(strArg); const common::SettingsValue value = GetSetting(strArg);
return SettingToBool(value); return SettingToBool(value);
} }
std::optional<bool> SettingToBool(const util::SettingsValue& value) std::optional<bool> SettingToBool(const common::SettingsValue& value)
{ {
if (value.isNull()) return std::nullopt; if (value.isNull()) return std::nullopt;
if (value.isBool()) return value.get_bool(); if (value.isBool()) return value.get_bool();
return InterpretBool(value.get_str()); return InterpretBool(value.get_str());
} }
bool SettingToBool(const util::SettingsValue& value, bool fDefault) bool SettingToBool(const common::SettingsValue& value, bool fDefault)
{ {
return SettingToBool(value).value_or(fDefault); return SettingToBool(value).value_or(fDefault);
} }
@@ -738,7 +738,7 @@ std::variant<ChainType, std::string> ArgsManager::GetChainArg() const
{ {
auto get_net = [&](const std::string& arg) { auto get_net = [&](const std::string& arg) {
LOCK(cs_args); LOCK(cs_args);
util::SettingsValue value = util::GetSetting(m_settings, /* section= */ "", SettingName(arg), common::SettingsValue value = common::GetSetting(m_settings, /* section= */ "", SettingName(arg),
/* ignore_default_section_config= */ false, /* ignore_default_section_config= */ false,
/*ignore_nonpersistent=*/false, /*ignore_nonpersistent=*/false,
/* get_chain_type= */ true); /* get_chain_type= */ true);
@@ -769,24 +769,24 @@ bool ArgsManager::UseDefaultSection(const std::string& arg) const
return m_network == ChainTypeToString(ChainType::MAIN) || m_network_only_args.count(arg) == 0; return m_network == ChainTypeToString(ChainType::MAIN) || m_network_only_args.count(arg) == 0;
} }
util::SettingsValue ArgsManager::GetSetting(const std::string& arg) const common::SettingsValue ArgsManager::GetSetting(const std::string& arg) const
{ {
LOCK(cs_args); LOCK(cs_args);
return util::GetSetting( return common::GetSetting(
m_settings, m_network, SettingName(arg), !UseDefaultSection(arg), m_settings, m_network, SettingName(arg), !UseDefaultSection(arg),
/*ignore_nonpersistent=*/false, /*get_chain_type=*/false); /*ignore_nonpersistent=*/false, /*get_chain_type=*/false);
} }
std::vector<util::SettingsValue> ArgsManager::GetSettingsList(const std::string& arg) const std::vector<common::SettingsValue> ArgsManager::GetSettingsList(const std::string& arg) const
{ {
LOCK(cs_args); LOCK(cs_args);
return util::GetSettingsList(m_settings, m_network, SettingName(arg), !UseDefaultSection(arg)); return common::GetSettingsList(m_settings, m_network, SettingName(arg), !UseDefaultSection(arg));
} }
void ArgsManager::logArgsPrefix( void ArgsManager::logArgsPrefix(
const std::string& prefix, const std::string& prefix,
const std::string& section, const std::string& section,
const std::map<std::string, std::vector<util::SettingsValue>>& args) const const std::map<std::string, std::vector<common::SettingsValue>>& args) const
{ {
std::string section_str = section.empty() ? "" : "[" + section + "] "; std::string section_str = section.empty() ? "" : "[" + section + "] ";
for (const auto& arg : args) { for (const auto& arg : args) {
+12 -12
View File
@@ -75,7 +75,7 @@ struct KeyInfo {
KeyInfo InterpretKey(std::string key); KeyInfo InterpretKey(std::string key);
std::optional<util::SettingsValue> InterpretValue(const KeyInfo& key, const std::string* value, std::optional<common::SettingsValue> InterpretValue(const KeyInfo& key, const std::string* value,
unsigned int flags, std::string& error); unsigned int flags, std::string& error);
struct SectionInfo { struct SectionInfo {
@@ -84,14 +84,14 @@ struct SectionInfo {
int m_line; int m_line;
}; };
std::string SettingToString(const util::SettingsValue&, const std::string&); std::string SettingToString(const common::SettingsValue&, const std::string&);
std::optional<std::string> SettingToString(const util::SettingsValue&); std::optional<std::string> SettingToString(const common::SettingsValue&);
int64_t SettingToInt(const util::SettingsValue&, int64_t); int64_t SettingToInt(const common::SettingsValue&, int64_t);
std::optional<int64_t> SettingToInt(const util::SettingsValue&); std::optional<int64_t> SettingToInt(const common::SettingsValue&);
bool SettingToBool(const util::SettingsValue&, bool); bool SettingToBool(const common::SettingsValue&, bool);
std::optional<bool> SettingToBool(const util::SettingsValue&); std::optional<bool> SettingToBool(const common::SettingsValue&);
class ArgsManager class ArgsManager
{ {
@@ -130,7 +130,7 @@ protected:
}; };
mutable RecursiveMutex cs_args; mutable RecursiveMutex cs_args;
util::Settings m_settings GUARDED_BY(cs_args); common::Settings m_settings GUARDED_BY(cs_args);
std::vector<std::string> m_command GUARDED_BY(cs_args); std::vector<std::string> m_command GUARDED_BY(cs_args);
std::string m_network GUARDED_BY(cs_args); std::string m_network GUARDED_BY(cs_args);
std::set<std::string> m_network_only_args GUARDED_BY(cs_args); std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
@@ -159,12 +159,12 @@ protected:
* false if "-nosetting" argument was passed, and a string if a "-setting=value" * false if "-nosetting" argument was passed, and a string if a "-setting=value"
* argument was passed. * argument was passed.
*/ */
util::SettingsValue GetSetting(const std::string& arg) const; common::SettingsValue GetSetting(const std::string& arg) const;
/** /**
* Get list of setting values. * Get list of setting values.
*/ */
std::vector<util::SettingsValue> GetSettingsList(const std::string& arg) const; std::vector<common::SettingsValue> GetSettingsList(const std::string& arg) const;
ArgsManager(); ArgsManager();
~ArgsManager(); ~ArgsManager();
@@ -394,7 +394,7 @@ protected:
* Get current setting from config file or read/write settings file, * Get current setting from config file or read/write settings file,
* ignoring nonpersistent command line or forced settings values. * ignoring nonpersistent command line or forced settings values.
*/ */
util::SettingsValue GetPersistentSetting(const std::string& name) const; common::SettingsValue GetPersistentSetting(const std::string& name) const;
/** /**
* Access settings with lock held. * Access settings with lock held.
@@ -433,7 +433,7 @@ private:
void logArgsPrefix( void logArgsPrefix(
const std::string& prefix, const std::string& prefix,
const std::string& section, const std::string& section,
const std::map<std::string, std::vector<util::SettingsValue>>& args) const; const std::map<std::string, std::vector<common::SettingsValue>>& args) const;
}; };
extern ArgsManager gArgs; extern ArgsManager gArgs;
+6 -6
View File
@@ -98,7 +98,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
std::optional<unsigned int> flags = GetArgFlags('-' + key.name); std::optional<unsigned int> flags = GetArgFlags('-' + key.name);
if (!IsConfSupported(key, error)) return false; if (!IsConfSupported(key, error)) return false;
if (flags) { if (flags) {
std::optional<util::SettingsValue> value = InterpretValue(key, &option.second, *flags, error); std::optional<common::SettingsValue> value = InterpretValue(key, &option.second, *flags, error);
if (!value) { if (!value) {
return false; return false;
} }
@@ -142,9 +142,9 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
bool use_conf_file{true}; bool use_conf_file{true};
{ {
LOCK(cs_args); LOCK(cs_args);
if (auto* includes = util::FindKey(m_settings.command_line_options, "includeconf")) { if (auto* includes = common::FindKey(m_settings.command_line_options, "includeconf")) {
// ParseParameters() fails if a non-negated -includeconf is passed on the command-line // ParseParameters() fails if a non-negated -includeconf is passed on the command-line
assert(util::SettingsSpan(*includes).last_negated()); assert(common::SettingsSpan(*includes).last_negated());
use_conf_file = false; use_conf_file = false;
} }
} }
@@ -155,9 +155,9 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
auto add_includes = [&](const std::string& network, size_t skip = 0) { auto add_includes = [&](const std::string& network, size_t skip = 0) {
size_t num_values = 0; size_t num_values = 0;
LOCK(cs_args); LOCK(cs_args);
if (auto* section = util::FindKey(m_settings.ro_config, network)) { if (auto* section = common::FindKey(m_settings.ro_config, network)) {
if (auto* values = util::FindKey(*section, "includeconf")) { if (auto* values = common::FindKey(*section, "includeconf")) {
for (size_t i = std::max(skip, util::SettingsSpan(*values).negated()); i < values->size(); ++i) { for (size_t i = std::max(skip, common::SettingsSpan(*values).negated()); i < values->size(); ++i) {
conf_file_names.push_back((*values)[i].get_str()); conf_file_names.push_back((*values)[i].get_str());
} }
num_values = values->size(); num_values = values->size();
+2 -2
View File
@@ -16,7 +16,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace util { namespace common {
namespace { namespace {
enum class Source { enum class Source {
@@ -258,4 +258,4 @@ size_t SettingsSpan::negated() const
return 0; return 0;
} }
} // namespace util } // namespace common
+2 -2
View File
@@ -14,7 +14,7 @@
class UniValue; class UniValue;
namespace util { namespace common {
//! Settings value type (string/integer/boolean/null variant). //! Settings value type (string/integer/boolean/null variant).
//! //!
@@ -110,6 +110,6 @@ auto FindKey(Map&& map, Key&& key) -> decltype(&map.at(key))
return it == map.end() ? nullptr : &it->second; return it == map.end() ? nullptr : &it->second;
} }
} // namespace util } // namespace common
#endif // BITCOIN_COMMON_SETTINGS_H #endif // BITCOIN_COMMON_SETTINGS_H
+4 -4
View File
@@ -300,17 +300,17 @@ public:
virtual int rpcSerializationFlags() = 0; virtual int rpcSerializationFlags() = 0;
//! Get settings value. //! Get settings value.
virtual util::SettingsValue getSetting(const std::string& arg) = 0; virtual common::SettingsValue getSetting(const std::string& arg) = 0;
//! Get list of settings values. //! Get list of settings values.
virtual std::vector<util::SettingsValue> getSettingsList(const std::string& arg) = 0; virtual std::vector<common::SettingsValue> getSettingsList(const std::string& arg) = 0;
//! Return <datadir>/settings.json setting value. //! Return <datadir>/settings.json setting value.
virtual util::SettingsValue getRwSetting(const std::string& name) = 0; virtual common::SettingsValue getRwSetting(const std::string& name) = 0;
//! Write a setting to <datadir>/settings.json. Optionally just update the //! Write a setting to <datadir>/settings.json. Optionally just update the
//! setting in memory and do not write the file. //! setting in memory and do not write the file.
virtual bool updateRwSetting(const std::string& name, const util::SettingsValue& value, bool write=true) = 0; virtual bool updateRwSetting(const std::string& name, const common::SettingsValue& value, bool write=true) = 0;
//! Synchronously send transactionAddedToMempool notifications about all //! Synchronously send transactionAddedToMempool notifications about all
//! current mempool transactions to the specified handler and return after //! current mempool transactions to the specified handler and return after
+3 -3
View File
@@ -103,14 +103,14 @@ public:
virtual bool isSettingIgnored(const std::string& name) = 0; virtual bool isSettingIgnored(const std::string& name) = 0;
//! Return setting value from <datadir>/settings.json or bitcoin.conf. //! Return setting value from <datadir>/settings.json or bitcoin.conf.
virtual util::SettingsValue getPersistentSetting(const std::string& name) = 0; virtual common::SettingsValue getPersistentSetting(const std::string& name) = 0;
//! Update a setting in <datadir>/settings.json. //! Update a setting in <datadir>/settings.json.
virtual void updateRwSetting(const std::string& name, const util::SettingsValue& value) = 0; virtual void updateRwSetting(const std::string& name, const common::SettingsValue& value) = 0;
//! Force a setting value to be applied, overriding any other configuration //! Force a setting value to be applied, overriding any other configuration
//! source, but not being persisted. //! source, but not being persisted.
virtual void forceSetting(const std::string& name, const util::SettingsValue& value) = 0; virtual void forceSetting(const std::string& name, const common::SettingsValue& value) = 0;
//! Clear all settings in <datadir>/settings.json and store a backup of //! Clear all settings in <datadir>/settings.json and store a backup of
//! previous settings in <datadir>/settings.json.bak. //! previous settings in <datadir>/settings.json.bak.
+16 -16
View File
@@ -125,17 +125,17 @@ public:
bool isSettingIgnored(const std::string& name) override bool isSettingIgnored(const std::string& name) override
{ {
bool ignored = false; bool ignored = false;
args().LockSettings([&](util::Settings& settings) { args().LockSettings([&](common::Settings& settings) {
if (auto* options = util::FindKey(settings.command_line_options, name)) { if (auto* options = common::FindKey(settings.command_line_options, name)) {
ignored = !options->empty(); ignored = !options->empty();
} }
}); });
return ignored; return ignored;
} }
util::SettingsValue getPersistentSetting(const std::string& name) override { return args().GetPersistentSetting(name); } common::SettingsValue getPersistentSetting(const std::string& name) override { return args().GetPersistentSetting(name); }
void updateRwSetting(const std::string& name, const util::SettingsValue& value) override void updateRwSetting(const std::string& name, const common::SettingsValue& value) override
{ {
args().LockSettings([&](util::Settings& settings) { args().LockSettings([&](common::Settings& settings) {
if (value.isNull()) { if (value.isNull()) {
settings.rw_settings.erase(name); settings.rw_settings.erase(name);
} else { } else {
@@ -144,9 +144,9 @@ public:
}); });
args().WriteSettingsFile(); args().WriteSettingsFile();
} }
void forceSetting(const std::string& name, const util::SettingsValue& value) override void forceSetting(const std::string& name, const common::SettingsValue& value) override
{ {
args().LockSettings([&](util::Settings& settings) { args().LockSettings([&](common::Settings& settings) {
if (value.isNull()) { if (value.isNull()) {
settings.forced_settings.erase(name); settings.forced_settings.erase(name);
} else { } else {
@@ -157,7 +157,7 @@ public:
void resetSettings() override void resetSettings() override
{ {
args().WriteSettingsFile(/*errors=*/nullptr, /*backup=*/true); args().WriteSettingsFile(/*errors=*/nullptr, /*backup=*/true);
args().LockSettings([&](util::Settings& settings) { args().LockSettings([&](common::Settings& settings) {
settings.rw_settings.clear(); settings.rw_settings.clear();
}); });
args().WriteSettingsFile(); args().WriteSettingsFile();
@@ -744,27 +744,27 @@ public:
RPCRunLater(name, std::move(fn), seconds); RPCRunLater(name, std::move(fn), seconds);
} }
int rpcSerializationFlags() override { return RPCSerializationFlags(); } int rpcSerializationFlags() override { return RPCSerializationFlags(); }
util::SettingsValue getSetting(const std::string& name) override common::SettingsValue getSetting(const std::string& name) override
{ {
return args().GetSetting(name); return args().GetSetting(name);
} }
std::vector<util::SettingsValue> getSettingsList(const std::string& name) override std::vector<common::SettingsValue> getSettingsList(const std::string& name) override
{ {
return args().GetSettingsList(name); return args().GetSettingsList(name);
} }
util::SettingsValue getRwSetting(const std::string& name) override common::SettingsValue getRwSetting(const std::string& name) override
{ {
util::SettingsValue result; common::SettingsValue result;
args().LockSettings([&](const util::Settings& settings) { args().LockSettings([&](const common::Settings& settings) {
if (const util::SettingsValue* value = util::FindKey(settings.rw_settings, name)) { if (const common::SettingsValue* value = common::FindKey(settings.rw_settings, name)) {
result = *value; result = *value;
} }
}); });
return result; return result;
} }
bool updateRwSetting(const std::string& name, const util::SettingsValue& value, bool write) override bool updateRwSetting(const std::string& name, const common::SettingsValue& value, bool write) override
{ {
args().LockSettings([&](util::Settings& settings) { args().LockSettings([&](common::Settings& settings) {
if (value.isNull()) { if (value.isNull()) {
settings.rw_settings.erase(name); settings.rw_settings.erase(name);
} else { } else {
+8 -8
View File
@@ -60,7 +60,7 @@ static const char* SettingName(OptionsModel::OptionID option)
} }
/** Call node.updateRwSetting() with Bitcoin 22.x workaround. */ /** Call node.updateRwSetting() with Bitcoin 22.x workaround. */
static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID option, const std::string& suffix, const util::SettingsValue& value) static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID option, const std::string& suffix, const common::SettingsValue& value)
{ {
if (value.isNum() && if (value.isNum() &&
(option == OptionsModel::DatabaseCache || (option == OptionsModel::DatabaseCache ||
@@ -81,14 +81,14 @@ static void UpdateRwSetting(interfaces::Node& node, OptionsModel::OptionID optio
} }
//! Convert enabled/size values to bitcoin -prune setting. //! Convert enabled/size values to bitcoin -prune setting.
static util::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb) static common::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
{ {
assert(!prune_enabled || prune_size_gb >= 1); // PruneSizeGB and ParsePruneSizeGB never return less assert(!prune_enabled || prune_size_gb >= 1); // PruneSizeGB and ParsePruneSizeGB never return less
return prune_enabled ? PruneGBtoMiB(prune_size_gb) : 0; return prune_enabled ? PruneGBtoMiB(prune_size_gb) : 0;
} }
//! Get pruning enabled value to show in GUI from bitcoin -prune setting. //! Get pruning enabled value to show in GUI from bitcoin -prune setting.
static bool PruneEnabled(const util::SettingsValue& prune_setting) static bool PruneEnabled(const common::SettingsValue& prune_setting)
{ {
// -prune=1 setting is manual pruning mode, so disabled for purposes of the gui // -prune=1 setting is manual pruning mode, so disabled for purposes of the gui
return SettingToInt(prune_setting, 0) > 1; return SettingToInt(prune_setting, 0) > 1;
@@ -96,7 +96,7 @@ static bool PruneEnabled(const util::SettingsValue& prune_setting)
//! Get pruning size value to show in GUI from bitcoin -prune setting. If //! Get pruning size value to show in GUI from bitcoin -prune setting. If
//! pruning is not enabled, just show default recommended pruning size (2GB). //! pruning is not enabled, just show default recommended pruning size (2GB).
static int PruneSizeGB(const util::SettingsValue& prune_setting) static int PruneSizeGB(const common::SettingsValue& prune_setting)
{ {
int value = SettingToInt(prune_setting, 0); int value = SettingToInt(prune_setting, 0);
return value > 1 ? PruneMiBtoGB(value) : DEFAULT_PRUNE_TARGET_GB; return value > 1 ? PruneMiBtoGB(value) : DEFAULT_PRUNE_TARGET_GB;
@@ -311,8 +311,8 @@ static QString GetDefaultProxyAddress()
void OptionsModel::SetPruneTargetGB(int prune_target_gb) void OptionsModel::SetPruneTargetGB(int prune_target_gb)
{ {
const util::SettingsValue cur_value = node().getPersistentSetting("prune"); const common::SettingsValue cur_value = node().getPersistentSetting("prune");
const util::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb); const common::SettingsValue new_value = PruneSetting(prune_target_gb > 0, prune_target_gb);
// Force setting to take effect. It is still safe to change the value at // Force setting to take effect. It is still safe to change the value at
// this point because this function is only called after the intro screen is // this point because this function is only called after the intro screen is
@@ -331,7 +331,7 @@ void OptionsModel::SetPruneTargetGB(int prune_target_gb)
// Keep previous pruning size, if pruning was disabled. // Keep previous pruning size, if pruning was disabled.
if (PruneEnabled(cur_value)) { if (PruneEnabled(cur_value)) {
UpdateRwSetting(node(), Prune, "-prev", PruneEnabled(new_value) ? util::SettingsValue{} : cur_value); UpdateRwSetting(node(), Prune, "-prev", PruneEnabled(new_value) ? common::SettingsValue{} : cur_value);
} }
} }
@@ -457,7 +457,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::string& suffix) bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::string& suffix)
{ {
auto changed = [&] { return value.isValid() && value != getOption(option, suffix); }; auto changed = [&] { return value.isValid() && value != getOption(option, suffix); };
auto update = [&](const util::SettingsValue& value) { return UpdateRwSetting(node(), option, suffix, value); }; auto update = [&](const common::SettingsValue& value) { return UpdateRwSetting(node(), option, suffix, value); };
bool successful = true; /* set to false on parse error */ bool successful = true; /* set to false on parse error */
QSettings settings; QSettings settings;
+5 -5
View File
@@ -18,13 +18,13 @@
OptionTests::OptionTests(interfaces::Node& node) : m_node(node) OptionTests::OptionTests(interfaces::Node& node) : m_node(node)
{ {
gArgs.LockSettings([&](util::Settings& s) { m_previous_settings = s; }); gArgs.LockSettings([&](common::Settings& s) { m_previous_settings = s; });
} }
void OptionTests::init() void OptionTests::init()
{ {
// reset args // reset args
gArgs.LockSettings([&](util::Settings& s) { s = m_previous_settings; }); gArgs.LockSettings([&](common::Settings& s) { s = m_previous_settings; });
gArgs.ClearPathCache(); gArgs.ClearPathCache();
} }
@@ -76,14 +76,14 @@ void OptionTests::integerGetArgBug()
// Test regression https://github.com/bitcoin/bitcoin/issues/24457. Ensure // Test regression https://github.com/bitcoin/bitcoin/issues/24457. Ensure
// that setting integer prune value doesn't cause an exception to be thrown // that setting integer prune value doesn't cause an exception to be thrown
// in the OptionsModel constructor // in the OptionsModel constructor
gArgs.LockSettings([&](util::Settings& settings) { gArgs.LockSettings([&](common::Settings& settings) {
settings.forced_settings.erase("prune"); settings.forced_settings.erase("prune");
settings.rw_settings["prune"] = 3814; settings.rw_settings["prune"] = 3814;
}); });
gArgs.WriteSettingsFile(); gArgs.WriteSettingsFile();
bilingual_str error; bilingual_str error;
QVERIFY(OptionsModel{m_node}.Init(error)); QVERIFY(OptionsModel{m_node}.Init(error));
gArgs.LockSettings([&](util::Settings& settings) { gArgs.LockSettings([&](common::Settings& settings) {
settings.rw_settings.erase("prune"); settings.rw_settings.erase("prune");
}); });
gArgs.WriteSettingsFile(); gArgs.WriteSettingsFile();
@@ -95,7 +95,7 @@ void OptionTests::parametersInteraction()
// It was fixed via https://github.com/bitcoin-core/gui/pull/568. // It was fixed via https://github.com/bitcoin-core/gui/pull/568.
// With fListen=false in ~/.config/Bitcoin/Bitcoin-Qt.conf and all else left as default, // With fListen=false in ~/.config/Bitcoin/Bitcoin-Qt.conf and all else left as default,
// bitcoin-qt should set both -listen and -listenonion to false and start successfully. // bitcoin-qt should set both -listen and -listenonion to false and start successfully.
gArgs.LockSettings([&](util::Settings& s) { gArgs.LockSettings([&](common::Settings& s) {
s.forced_settings.erase("listen"); s.forced_settings.erase("listen");
s.forced_settings.erase("listenonion"); s.forced_settings.erase("listenonion");
}); });
+1 -1
View File
@@ -26,7 +26,7 @@ private Q_SLOTS:
private: private:
interfaces::Node& m_node; interfaces::Node& m_node;
util::Settings m_previous_settings; common::Settings m_previous_settings;
}; };
#endif // BITCOIN_QT_TEST_OPTIONTESTS_H #endif // BITCOIN_QT_TEST_OPTIONTESTS_H
+4 -4
View File
@@ -85,7 +85,7 @@ class CheckValueTest : public TestChain100Setup
{ {
public: public:
struct Expect { struct Expect {
util::SettingsValue setting; common::SettingsValue setting;
bool default_string = false; bool default_string = false;
bool default_int = false; bool default_int = false;
bool default_bool = false; bool default_bool = false;
@@ -95,7 +95,7 @@ public:
std::optional<std::vector<std::string>> list_value; std::optional<std::vector<std::string>> list_value;
const char* error = nullptr; const char* error = nullptr;
explicit Expect(util::SettingsValue s) : setting(std::move(s)) {} explicit Expect(common::SettingsValue s) : setting(std::move(s)) {}
Expect& DefaultString() { default_string = true; return *this; } Expect& DefaultString() { default_string = true; return *this; }
Expect& DefaultInt() { default_int = true; return *this; } Expect& DefaultInt() { default_int = true; return *this; }
Expect& DefaultBool() { default_bool = true; return *this; } Expect& DefaultBool() { default_bool = true; return *this; }
@@ -1022,14 +1022,14 @@ BOOST_AUTO_TEST_CASE(util_ReadWriteSettings)
// Test writing setting. // Test writing setting.
TestArgsManager args1; TestArgsManager args1;
args1.ForceSetArg("-datadir", fs::PathToString(m_path_root)); args1.ForceSetArg("-datadir", fs::PathToString(m_path_root));
args1.LockSettings([&](util::Settings& settings) { settings.rw_settings["name"] = "value"; }); args1.LockSettings([&](common::Settings& settings) { settings.rw_settings["name"] = "value"; });
args1.WriteSettingsFile(); args1.WriteSettingsFile();
// Test reading setting. // Test reading setting.
TestArgsManager args2; TestArgsManager args2;
args2.ForceSetArg("-datadir", fs::PathToString(m_path_root)); args2.ForceSetArg("-datadir", fs::PathToString(m_path_root));
args2.ReadSettingsFile(); args2.ReadSettingsFile();
args2.LockSettings([&](util::Settings& settings) { BOOST_CHECK_EQUAL(settings.rw_settings["name"].get_str(), "value"); }); args2.LockSettings([&](common::Settings& settings) { BOOST_CHECK_EQUAL(settings.rw_settings["name"].get_str(), "value"); });
// Test error logging, and remove previously written setting. // Test error logging, and remove previously written setting.
{ {
+1 -1
View File
@@ -63,7 +63,7 @@ FUZZ_TARGET(string)
(void)IsDeprecatedRPCEnabled(random_string_1); (void)IsDeprecatedRPCEnabled(random_string_1);
(void)Join(random_string_vector, random_string_1); (void)Join(random_string_vector, random_string_1);
(void)JSONRPCError(fuzzed_data_provider.ConsumeIntegral<int>(), random_string_1); (void)JSONRPCError(fuzzed_data_provider.ConsumeIntegral<int>(), random_string_1);
const util::Settings settings; const common::Settings settings;
(void)OnlyHasDefaultSectionSetting(settings, random_string_1, random_string_2); (void)OnlyHasDefaultSectionSetting(settings, random_string_1, random_string_2);
(void)ParseNetwork(random_string_1); (void)ParseNetwork(random_string_1);
try { try {
+2 -2
View File
@@ -57,8 +57,8 @@ BOOST_AUTO_TEST_CASE(setting_args)
ArgsManager args; ArgsManager args;
SetupArgs(args, {{"-foo", ArgsManager::ALLOW_ANY}}); SetupArgs(args, {{"-foo", ArgsManager::ALLOW_ANY}});
auto set_foo = [&](const util::SettingsValue& value) { auto set_foo = [&](const common::SettingsValue& value) {
args.LockSettings([&](util::Settings& settings) { args.LockSettings([&](common::Settings& settings) {
settings.rw_settings["foo"] = value; settings.rw_settings["foo"] = value;
}); });
}; };
+19 -19
View File
@@ -21,20 +21,20 @@
#include <system_error> #include <system_error>
#include <vector> #include <vector>
inline bool operator==(const util::SettingsValue& a, const util::SettingsValue& b) inline bool operator==(const common::SettingsValue& a, const common::SettingsValue& b)
{ {
return a.write() == b.write(); return a.write() == b.write();
} }
inline std::ostream& operator<<(std::ostream& os, const util::SettingsValue& value) inline std::ostream& operator<<(std::ostream& os, const common::SettingsValue& value)
{ {
os << value.write(); os << value.write();
return os; return os;
} }
inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, util::SettingsValue>& kv) inline std::ostream& operator<<(std::ostream& os, const std::pair<std::string, common::SettingsValue>& kv)
{ {
util::SettingsValue out(util::SettingsValue::VOBJ); common::SettingsValue out(common::SettingsValue::VOBJ);
out.__pushKV(kv.first, kv.second); out.__pushKV(kv.first, kv.second);
os << out.write(); os << out.write();
return os; return os;
@@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(ReadWrite)
"null": null "null": null
})"); })");
std::map<std::string, util::SettingsValue> expected{ std::map<std::string, common::SettingsValue> expected{
{"string", "string"}, {"string", "string"},
{"num", 5}, {"num", 5},
{"bool", true}, {"bool", true},
@@ -68,15 +68,15 @@ BOOST_AUTO_TEST_CASE(ReadWrite)
}; };
// Check file read. // Check file read.
std::map<std::string, util::SettingsValue> values; std::map<std::string, common::SettingsValue> values;
std::vector<std::string> errors; std::vector<std::string> errors;
BOOST_CHECK(util::ReadSettings(path, values, errors)); BOOST_CHECK(common::ReadSettings(path, values, errors));
BOOST_CHECK_EQUAL_COLLECTIONS(values.begin(), values.end(), expected.begin(), expected.end()); BOOST_CHECK_EQUAL_COLLECTIONS(values.begin(), values.end(), expected.begin(), expected.end());
BOOST_CHECK(errors.empty()); BOOST_CHECK(errors.empty());
// Check no errors if file doesn't exist. // Check no errors if file doesn't exist.
fs::remove(path); fs::remove(path);
BOOST_CHECK(util::ReadSettings(path, values, errors)); BOOST_CHECK(common::ReadSettings(path, values, errors));
BOOST_CHECK(values.empty()); BOOST_CHECK(values.empty());
BOOST_CHECK(errors.empty()); BOOST_CHECK(errors.empty());
@@ -85,29 +85,29 @@ BOOST_AUTO_TEST_CASE(ReadWrite)
"dupe": "string", "dupe": "string",
"dupe": "dupe" "dupe": "dupe"
})"); })");
BOOST_CHECK(!util::ReadSettings(path, values, errors)); BOOST_CHECK(!common::ReadSettings(path, values, errors));
std::vector<std::string> dup_keys = {strprintf("Found duplicate key dupe in settings file %s", fs::PathToString(path))}; std::vector<std::string> dup_keys = {strprintf("Found duplicate key dupe in settings file %s", fs::PathToString(path))};
BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), dup_keys.begin(), dup_keys.end()); BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), dup_keys.begin(), dup_keys.end());
BOOST_CHECK(values.empty()); BOOST_CHECK(values.empty());
// Check non-kv json files not allowed // Check non-kv json files not allowed
WriteText(path, R"("non-kv")"); WriteText(path, R"("non-kv")");
BOOST_CHECK(!util::ReadSettings(path, values, errors)); BOOST_CHECK(!common::ReadSettings(path, values, errors));
std::vector<std::string> non_kv = {strprintf("Found non-object value \"non-kv\" in settings file %s", fs::PathToString(path))}; std::vector<std::string> non_kv = {strprintf("Found non-object value \"non-kv\" in settings file %s", fs::PathToString(path))};
BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), non_kv.begin(), non_kv.end()); BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), non_kv.begin(), non_kv.end());
// Check invalid json not allowed // Check invalid json not allowed
WriteText(path, R"(invalid json)"); WriteText(path, R"(invalid json)");
BOOST_CHECK(!util::ReadSettings(path, values, errors)); BOOST_CHECK(!common::ReadSettings(path, values, errors));
std::vector<std::string> fail_parse = {strprintf("Unable to parse settings file %s", fs::PathToString(path))}; std::vector<std::string> fail_parse = {strprintf("Unable to parse settings file %s", fs::PathToString(path))};
BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), fail_parse.begin(), fail_parse.end()); BOOST_CHECK_EQUAL_COLLECTIONS(errors.begin(), errors.end(), fail_parse.begin(), fail_parse.end());
} }
//! Check settings struct contents against expected json strings. //! Check settings struct contents against expected json strings.
static void CheckValues(const util::Settings& settings, const std::string& single_val, const std::string& list_val) static void CheckValues(const common::Settings& settings, const std::string& single_val, const std::string& list_val)
{ {
util::SettingsValue single_value = GetSetting(settings, "section", "name", false, false, false); common::SettingsValue single_value = GetSetting(settings, "section", "name", false, false, false);
util::SettingsValue list_value(util::SettingsValue::VARR); common::SettingsValue list_value(common::SettingsValue::VARR);
for (const auto& item : GetSettingsList(settings, "section", "name", false)) { for (const auto& item : GetSettingsList(settings, "section", "name", false)) {
list_value.push_back(item); list_value.push_back(item);
} }
@@ -118,7 +118,7 @@ static void CheckValues(const util::Settings& settings, const std::string& singl
// Simple settings merge test case. // Simple settings merge test case.
BOOST_AUTO_TEST_CASE(Simple) BOOST_AUTO_TEST_CASE(Simple)
{ {
util::Settings settings; common::Settings settings;
settings.command_line_options["name"].push_back("val1"); settings.command_line_options["name"].push_back("val1");
settings.command_line_options["name"].push_back("val2"); settings.command_line_options["name"].push_back("val2");
settings.ro_config["section"]["name"].push_back(2); settings.ro_config["section"]["name"].push_back(2);
@@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(Simple)
// The last given arg takes precedence when specified via commandline. // The last given arg takes precedence when specified via commandline.
CheckValues(settings, R"("val2")", R"(["val1","val2",2])"); CheckValues(settings, R"("val2")", R"(["val1","val2",2])");
util::Settings settings2; common::Settings settings2;
settings2.ro_config["section"]["name"].push_back("val2"); settings2.ro_config["section"]["name"].push_back("val2");
settings2.ro_config["section"]["name"].push_back("val3"); settings2.ro_config["section"]["name"].push_back("val3");
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(Simple)
// its default value. // its default value.
BOOST_AUTO_TEST_CASE(NullOverride) BOOST_AUTO_TEST_CASE(NullOverride)
{ {
util::Settings settings; common::Settings settings;
settings.command_line_options["name"].push_back("value"); settings.command_line_options["name"].push_back("value");
BOOST_CHECK_EQUAL(R"("value")", GetSetting(settings, "section", "name", false, false, false).write().c_str()); BOOST_CHECK_EQUAL(R"("value")", GetSetting(settings, "section", "name", false, false, false).write().c_str());
settings.forced_settings["name"] = {}; settings.forced_settings["name"] = {};
@@ -195,11 +195,11 @@ BOOST_FIXTURE_TEST_CASE(Merge, MergeTestingSetup)
bool ignore_default_section_config) { bool ignore_default_section_config) {
std::string desc; std::string desc;
int value_suffix = 0; int value_suffix = 0;
util::Settings settings; common::Settings settings;
const std::string& name = ignore_default_section_config ? "wallet" : "server"; const std::string& name = ignore_default_section_config ? "wallet" : "server";
auto push_values = [&](Action action, const char* value_prefix, const std::string& name_prefix, auto push_values = [&](Action action, const char* value_prefix, const std::string& name_prefix,
std::vector<util::SettingsValue>& dest) { std::vector<common::SettingsValue>& dest) {
if (action == SET || action == SECTION_SET) { if (action == SET || action == SECTION_SET) {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
dest.push_back(value_prefix + ToString(++value_suffix)); dest.push_back(value_prefix + ToString(++value_suffix));
+1 -1
View File
@@ -62,7 +62,7 @@ bool VerifyWallets(WalletContext& context)
options.require_existing = true; options.require_existing = true;
options.verify = false; options.verify = false;
if (MakeWalletDatabase("", options, status, error_string)) { if (MakeWalletDatabase("", options, status, error_string)) {
util::SettingsValue wallets(util::SettingsValue::VARR); common::SettingsValue wallets(common::SettingsValue::VARR);
wallets.push_back(""); // Default wallet name is "" wallets.push_back(""); // Default wallet name is ""
// Pass write=false because no need to write file and probably // Pass write=false because no need to write file and probably
// better not to. If unnamed wallet needs to be added next startup // better not to. If unnamed wallet needs to be added next startup
+7 -7
View File
@@ -56,9 +56,9 @@ namespace wallet {
bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name) bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name)
{ {
util::SettingsValue setting_value = chain.getRwSetting("wallet"); common::SettingsValue setting_value = chain.getRwSetting("wallet");
if (!setting_value.isArray()) setting_value.setArray(); if (!setting_value.isArray()) setting_value.setArray();
for (const util::SettingsValue& value : setting_value.getValues()) { for (const common::SettingsValue& value : setting_value.getValues()) {
if (value.isStr() && value.get_str() == wallet_name) return true; if (value.isStr() && value.get_str() == wallet_name) return true;
} }
setting_value.push_back(wallet_name); setting_value.push_back(wallet_name);
@@ -67,10 +67,10 @@ bool AddWalletSetting(interfaces::Chain& chain, const std::string& wallet_name)
bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name) bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_name)
{ {
util::SettingsValue setting_value = chain.getRwSetting("wallet"); common::SettingsValue setting_value = chain.getRwSetting("wallet");
if (!setting_value.isArray()) return true; if (!setting_value.isArray()) return true;
util::SettingsValue new_value(util::SettingsValue::VARR); common::SettingsValue new_value(common::SettingsValue::VARR);
for (const util::SettingsValue& value : setting_value.getValues()) { for (const common::SettingsValue& value : setting_value.getValues()) {
if (!value.isStr() || value.get_str() != wallet_name) new_value.push_back(value); if (!value.isStr() || value.get_str() != wallet_name) new_value.push_back(value);
} }
if (new_value.size() == setting_value.size()) return true; if (new_value.size() == setting_value.size()) return true;
@@ -2832,7 +2832,7 @@ bool CWallet::SetAddressPreviouslySpent(WalletBatch& batch, const CTxDestination
return false; return false;
if (!used) { if (!used) {
if (auto* data{util::FindKey(m_address_book, dest)}) data->previously_spent = false; if (auto* data{common::FindKey(m_address_book, dest)}) data->previously_spent = false;
return batch.WriteAddressPreviouslySpent(dest, false); return batch.WriteAddressPreviouslySpent(dest, false);
} }
@@ -2852,7 +2852,7 @@ void CWallet::LoadAddressReceiveRequest(const CTxDestination& dest, const std::s
bool CWallet::IsAddressPreviouslySpent(const CTxDestination& dest) const bool CWallet::IsAddressPreviouslySpent(const CTxDestination& dest) const
{ {
if (auto* data{util::FindKey(m_address_book, dest)}) return data->previously_spent; if (auto* data{common::FindKey(m_address_book, dest)}) return data->previously_spent;
return false; return false;
} }