Skip to content

Commit 234b99b

Browse files
author
MarcoFalke
committed
Merge bitcoin#14885: rpc: Assert named arguments are unique in RPCHelpMan
e09a587 rpc: Assert named arguments are unique in RPCHelpMan (João Barbosa) Pull request description: Prevents an obvious mistake. Tree-SHA512: 32c24a1934b17ab6f0d5cd31bdf0388e93ee5156ccc1b4f78eb9fd7f1d4b27a4b978b594ff11812bc9f20987c9fc36bf4497ddaedf18cf6bcbea19c050571334
2 parents e946fc7 + e09a587 commit 234b99b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/rpc/util.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ struct Sections {
242242
}
243243
};
244244

245+
RPCHelpMan::RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
246+
: m_name{name}, m_description{description}, m_args{args}
247+
{
248+
std::set<std::string> named_args;
249+
for (const auto& arg : m_args) {
250+
// Should have unique named arguments
251+
assert(named_args.insert(arg.m_name).second);
252+
}
253+
}
254+
245255
std::string RPCHelpMan::ToString() const
246256
{
247257
std::string ret;

src/rpc/util.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ struct RPCArg {
109109
class RPCHelpMan
110110
{
111111
public:
112-
RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args)
113-
: m_name{name}, m_description{description}, m_args{args}
114-
{
115-
}
112+
RPCHelpMan(const std::string& name, const std::string& description, const std::vector<RPCArg>& args);
116113

117114
std::string ToString() const;
118115

0 commit comments

Comments
 (0)