From 6158a6d3978a18d5ac4166ca2f59056d8ef71c3d Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Fri, 29 Jan 2021 18:09:46 -0500 Subject: refactor: Replace JSONRPCRequest fHelp field with mode field No change in behavior --- src/rpc/util.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/rpc/util.cpp') diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index bfdba5253c..dc57d2be07 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -476,6 +476,18 @@ std::string RPCExamples::ToDescriptionString() const return m_examples.empty() ? m_examples : "\nExamples:\n" + m_examples; } +UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request) +{ + /* + * Check if the given request is valid according to this command or if + * the user is asking for help information, and throw help when appropriate. + */ + if (request.mode == JSONRPCRequest::GET_HELP || !IsValidNumArgs(request.params.size())) { + throw std::runtime_error(ToString()); + } + return m_fun(*this, request); +} + bool RPCHelpMan::IsValidNumArgs(size_t num_args) const { size_t num_required_args = 0; -- cgit v1.2.3