diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-06-26 12:16:22 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-06-30 14:11:11 -0400 |
commit | faaeb2b0b347b40ce456a951eec5e820587e5b02 (patch) | |
tree | 47ca1c984e43fbf5333377ec51154e9dbacc0e2c /src/rpc/util.cpp | |
parent | fa8ec00061567e56333bb69c5623919d45a9a92d (diff) | |
download | bitcoin-faaeb2b0b347b40ce456a951eec5e820587e5b02.tar.xz |
rpc: Add CRPCCommand constructor which takes RPCHelpMan
This allows the constructor to ask the rpc manager for the name of the
rpc method or the rpc argument names instead of having it manually
passed in.
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r-- | src/rpc/util.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index d476feb962..fbd51784a7 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -418,7 +418,11 @@ struct Sections { }; RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples) + : RPCHelpMan{std::move(name), std::move(description), std::move(args), std::move(results), std::move(examples), nullptr} {} + +RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples, RPCMethodImpl fun) : m_name{std::move(name)}, + m_fun{std::move(fun)}, m_description{std::move(description)}, m_args{std::move(args)}, m_results{std::move(results)}, @@ -467,6 +471,16 @@ bool RPCHelpMan::IsValidNumArgs(size_t num_args) const } return num_required_args <= num_args && num_args <= m_args.size(); } + +std::vector<std::string> RPCHelpMan::GetArgNames() const +{ + std::vector<std::string> ret; + for (const auto& arg : m_args) { + ret.emplace_back(arg.m_names); + } + return ret; +} + std::string RPCHelpMan::ToString() const { std::string ret; |