aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-10 10:26:27 -0500
committerMarcoFalke <falke.marco@gmail.com>2018-12-10 10:26:39 -0500
commit234b99b9210c0a18fca10dfa75331a68f8e74a13 (patch)
treec8d61845216a668e9cbfbbe4fe986ec8eb332d79
parente946fc7eb1db9f748cdf9e21a6bc952685adca51 (diff)
parente09a5875cac3e691bb9cc8301cb882d63b029cb0 (diff)
Merge #14885: rpc: Assert named arguments are unique in RPCHelpMan
e09a5875ca rpc: Assert named arguments are unique in RPCHelpMan (João Barbosa) Pull request description: Prevents an obvious mistake. Tree-SHA512: 32c24a1934b17ab6f0d5cd31bdf0388e93ee5156ccc1b4f78eb9fd7f1d4b27a4b978b594ff11812bc9f20987c9fc36bf4497ddaedf18cf6bcbea19c050571334
-rw-r--r--src/rpc/util.cpp10
-rw-r--r--src/rpc/util.h5
2 files changed, 11 insertions, 4 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index bb1c315bc7..740f8351fe 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -242,6 +242,16 @@ struct Sections {
}
};
+RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
+ : m_name{name}, m_description{description}, m_args{args}
+{
+ std::set<std::string> named_args;
+ for (const auto& arg : m_args) {
+ // Should have unique named arguments
+ assert(named_args.insert(arg.m_name).second);
+ }
+}
+
std::string RPCHelpMan::ToString() const
{
std::string ret;
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 1d1df2c635..7dedb915fb 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -109,10 +109,7 @@ struct RPCArg {
class RPCHelpMan
{
public:
- RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
- : m_name{name}, m_description{description}, m_args{args}
- {
- }
+ RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args);
std::string ToString() const;