https://github.com/bitcoin/bitcoin/commit/fa48d460334beef43fa73455aa9e30971d33c1b2 This seems like a lot of code for what could be 2 lines instead, and you could make the commands data structure an constexpr array constant and have it run in O(n) instead of O(log n) (and order the commands by probable frequency of invocation). The resulting code is self-explanatory, so could drop the comments too.
<details><summary>Suggested diff</summary><p>
@@ -53,6 +53,7 @@ using CliClock = std::chrono::system_clock;
+constexpr std::array<std::string_view, 4> CLI_COMMANDS{"-netinfo", "-getinfo", "-addrinfo", "-generate"};
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
@@ -1105,20 +1106,6 @@ static UniValue GetNewAddress()
-/**
- * IsExclusivelyCliCommand checks if a string is a cli-command that needs to run exclusively
- * [@param](/bitcoin-bitcoin/contributor/param/)[in] cli_command The string to check if it is a cli-command that needs to run exclusively.
- * [@returns](/bitcoin-bitcoin/contributor/returns/) true if cli_command is included in the set of the exclusively_commands.
- */
-bool IsExclusivelyCliCommand(const std::string_view cli_command)
-{
- // Initialize set with cli-commands that run exclusively
- const std::set<std::string_view> exclusively_commands{"-generate", "-netinfo", "-addrinfo", "-getinfo"};
-
- // return if element was found or not
- return (exclusively_commands.find(cli_command) != exclusively_commands.end());
-}
-
@@ -1131,38 +1118,26 @@ static void ValidateCliCommand(int argc, char *argv[])
- // Check if it's a cli-command that runs exclusively e.g. a user could run:
- // "bitcoin-cli -regtest -generate -netinfo -addrinfo -getinfo" but it's confusing,
- // only the last one will be executed so we make sure the user specify only one
- if (IsExclusivelyCliCommand(command)) {
+ if (std::find(std::begin(CLI_COMMANDS), std::end(CLI_COMMANDS), command) != std::end(CLI_COMMANDS)) {
</p></details>