Skip to content

Commit c99ab3c

Browse files
luke-jrachow101
authored andcommitted
RPC: Allow multiple names for parameters
1 parent e19586a commit c99ab3c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/rpc/server.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <boost/signals2/signal.hpp>
2323
#include <boost/thread.hpp>
2424
#include <boost/algorithm/string/case_conv.hpp> // for to_upper()
25+
#include <boost/algorithm/string/classification.hpp>
26+
#include <boost/algorithm/string/split.hpp>
2527

2628
#include <memory> // for unique_ptr
2729
#include <unordered_map>
@@ -432,8 +434,16 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
432434
}
433435
// Process expected parameters.
434436
int hole = 0;
435-
for (const std::string &argName: argNames) {
436-
auto fr = argsIn.find(argName);
437+
for (const std::string &argNamePattern: argNames) {
438+
std::vector<std::string> vargNames;
439+
boost::algorithm::split(vargNames, argNamePattern, boost::algorithm::is_any_of("|"));
440+
auto fr = argsIn.end();
441+
for (const std::string & argName : vargNames) {
442+
fr = argsIn.find(argName);
443+
if (fr != argsIn.end()) {
444+
break;
445+
}
446+
}
437447
if (fr != argsIn.end()) {
438448
for (int i = 0; i < hole; ++i) {
439449
// Fill hole between specified parameters with JSON nulls,

0 commit comments

Comments
 (0)