From 8d8a728ecb6f797cf57d6625102a32964a37bd75 Mon Sep 17 00:00:00 2001 From: Brandon Odiwuor Date: Thu, 30 May 2024 16:40:59 +0300 Subject: [PATCH] Add GetSectionArg() Helper Add helper function to read signet_chain args from config --- src/common/args.cpp | 15 +++++++++++++++ src/common/args.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/common/args.cpp b/src/common/args.cpp index 6a879fc070c04..e81e1c75b2886 100644 --- a/src/common/args.cpp +++ b/src/common/args.cpp @@ -379,6 +379,21 @@ std::optional ArgsManager::GetCommand() const return ret; } +std::vector ArgsManager::GetSectionArg(const std::string& section, const std::string& strArg) const +{ + std::vector result; + LOCK(cs_args); + if (auto* _section = common::FindKey(m_settings.ro_config, section)) { + if (auto* values = common::FindKey(*_section, strArg)) { + for (int i = 0; i < values->size(); i++) { + result.push_back((*values)[i]); + } + + } + } + return result; +} + std::vector ArgsManager::GetArgs(const std::string& strArg) const { std::vector result; diff --git a/src/common/args.h b/src/common/args.h index d7099f956e67a..8a5eeb269e666 100644 --- a/src/common/args.h +++ b/src/common/args.h @@ -244,6 +244,15 @@ class ArgsManager */ void ClearPathCache(); + /** + * Retrieves values associated with a specified argument in a given configuration section. + * + * @param section section in m_settings.ro_config to seach + * @param strArg Argument to get (e.g. "-foo") + * @return Vector of string values for the argument in the configuration file. + */ + std::vector GetSectionArg(const std::string& section, const std::string& strArg) const; + /** * Return a vector of strings of the given argument *