Make the RPCHelpMan aware of JSONRPCRequest and add Check() helper
This commit is contained in:
parent
5c5e32bbe3
commit
c7a9fc234f
1 changed files with 9 additions and 0 deletions
|
@ -243,6 +243,15 @@ public:
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
/** If the supplied number of args is neither too small nor too high */
|
/** If the supplied number of args is neither too small nor too high */
|
||||||
bool IsValidNumArgs(size_t num_args) const;
|
bool IsValidNumArgs(size_t num_args) const;
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
inline void Check(const JSONRPCRequest& request) const {
|
||||||
|
if (request.fHelp || !IsValidNumArgs(request.params.size())) {
|
||||||
|
throw std::runtime_error(ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string m_name;
|
const std::string m_name;
|
||||||
|
|
Loading…
Reference in a new issue