aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-06-26 12:16:22 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-06-30 14:11:11 -0400
commitfaaeb2b0b347b40ce456a951eec5e820587e5b02 (patch)
tree47ca1c984e43fbf5333377ec51154e9dbacc0e2c /src/rpc/util.h
parentfa8ec00061567e56333bb69c5623919d45a9a92d (diff)
downloadbitcoin-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.h')
-rw-r--r--src/rpc/util.h12
1 files changed, 11 insertions, 1 deletions
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<RPCArg> args, RPCResults results, RPCExamples examples);
+ using RPCMethodImpl = std::function<UniValue(const RPCHelpMan&, const JSONRPCRequest&)>;
+ RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> 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<std::string> GetArgNames() const;
+
const std::string m_name;
+
+private:
+ const RPCMethodImpl m_fun;
const std::string m_description;
const std::vector<RPCArg> m_args;
const RPCResults m_results;