remove CRPCCommand constructor that takes rpcfn_type function pointer

This commit is contained in:
MarcoFalke 2020-04-01 02:55:59 +02:00
parent fa19bb2cd8
commit faaf9c58e4
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
3 changed files with 17 additions and 38 deletions

View File

@ -14,14 +14,26 @@
#include <QDir> #include <QDir>
#include <QtGlobal> #include <QtGlobal>
static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request) static RPCHelpMan rpcNestedTest_rpc()
{ {
return request.params.write(0, 0); return RPCHelpMan{
"rpcNestedTest",
"echo the passed string(s)",
{
{"arg1", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
{"arg2", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
{"arg3", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
},
{},
RPCExamples{""},
[](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
return request.params.write(0, 0);
},
};
} }
static const CRPCCommand vRPCCommands[] = static const CRPCCommand vRPCCommands[] = {
{ {"test", "rpcNestedTest", &rpcNestedTest_rpc, {"arg1", "arg2", "arg3"}},
{ "test", "rpcNestedTest", &rpcNestedTest_rpc, {} },
}; };
void RPCNestedTests::rpcNestedTests() void RPCNestedTests::rpcNestedTests()

View File

@ -85,7 +85,6 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
*/ */
void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds); void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds);
typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);
typedef RPCHelpMan (*RpcMethodFnType)(); typedef RPCHelpMan (*RpcMethodFnType)();
class CRPCCommand class CRPCCommand
@ -116,14 +115,6 @@ public:
CHECK_NONFATAL(fn().GetArgNames() == args_in); CHECK_NONFATAL(fn().GetArgNames() == args_in);
} }
//! Simplified constructor taking plain rpcfn_type function pointer.
CRPCCommand(const char* category, const char* name, rpcfn_type fn, std::initializer_list<const char*> args)
: CRPCCommand(category, name,
[fn](const JSONRPCRequest& request, UniValue& result, bool) { result = fn(request); return true; },
{args.begin(), args.end()}, intptr_t(fn))
{
}
std::string category; std::string category;
std::string name; std::string name;
Actor actor; Actor actor;

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Check that all RPC help texts are generated by RPCHelpMan.
export LC_ALL=C
EXIT_CODE=0
# Assume that all multiline strings passed into a runtime_error are help texts.
# This is potentially fragile, but the linter is only temporary and can safely
# be removed early 2019.
non_autogenerated_help=$(grep --perl-regexp --null-data --only-matching 'runtime_error\(\n\s*".*\\n"\n' $(git ls-files -- "*.cpp"))
if [[ ${non_autogenerated_help} != "" ]]; then
echo "Must use RPCHelpMan to generate the help for the following RPC methods:"
echo "${non_autogenerated_help}"
echo
EXIT_CODE=1
fi
exit ${EXIT_CODE}