refactor: Replace JSONRPCRequest fHelp field with mode field

No change in behavior
This commit is contained in:
Russell Yanofsky
2021-01-29 18:09:46 -05:00
parent 80e16cadd5
commit 6158a6d397
6 changed files with 18 additions and 21 deletions

View File

@@ -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;