From faaeb2b0b347b40ce456a951eec5e820587e5b02 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 26 Jun 2020 12:16:22 -0400 Subject: 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. --- src/rpc/util.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/rpc/util.h') diff --git a/src/rpc/util.h b/src/rpc/util.h index 53dce2c397..49f603c8a1 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -326,8 +326,14 @@ class RPCHelpMan { public: RPCHelpMan(std::string name, std::string description, std::vector args, RPCResults results, RPCExamples examples); + using RPCMethodImpl = std::function; + RPCHelpMan(std::string name, std::string description, std::vector args, RPCResults results, RPCExamples examples, RPCMethodImpl fun); std::string ToString() const; + UniValue HandleRequest(const JSONRPCRequest& request) + { + return m_fun(*this, request); + } /** If the supplied number of args is neither too small nor too high */ bool IsValidNumArgs(size_t num_args) const; /** @@ -340,8 +346,12 @@ public: } } -private: + std::vector GetArgNames() const; + const std::string m_name; + +private: + const RPCMethodImpl m_fun; const std::string m_description; const std::vector m_args; const RPCResults m_results; -- cgit v1.2.3