Skip to content

Commit

Permalink
rpc: Assert named arguments are unique in RPCHelpMan
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Dec 7, 2018
1 parent e2c473f commit e09a587
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/rpc/util.cpp
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions src/rpc/util.h
Expand Up @@ -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;

Expand Down

0 comments on commit e09a587

Please sign in to comment.