6 #ifndef BITCOIN_RPC_SERVER_H 7 #define BITCOIN_RPC_SERVER_H 26 void OnStarted(std::function<
void ()> slot);
27 void OnStopped(std::function<
void ()> slot);
65 virtual const char *Name() = 0;
72 virtual RPCTimerBase* NewTimer(std::function<
void()>& func, int64_t millis) = 0;
86 void RPCRunLater(
const std::string&
name, std::function<
void()> func, int64_t nSeconds);
97 using Actor = std::function<bool(const JSONRPCRequest& request, UniValue& result, bool last_handler)>;
100 CRPCCommand(std::string category, std::string
name,
Actor actor, std::vector<std::string> args, intptr_t unique_id)
101 : category(
std::move(category)), name(
std::move(name)), actor(
std::move(actor)), argNames(
std::move(args)),
111 [fn](const
JSONRPCRequest& request,
UniValue& result, bool) { result = fn().HandleRequest(request);
return true; },
123 {args.begin(), args.end()}, intptr_t(fn))
140 std::map<std::string, std::vector<const CRPCCommand*>>
mapCommands;
157 std::vector<std::string> listCommands()
const;
188 #endif // BITCOIN_RPC_SERVER_H
bool IsRPCRunning()
Query whether RPC is running.
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION
CRPCCommand(std::string category, std::string name, Actor actor, std::vector< std::string > args, intptr_t unique_id)
Constructor taking Actor callback supporting multiple handlers.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
void SetRPCWarmupFinished()
void OnStopped(std::function< void()> slot)
RPCHelpMan(* RpcMethodFnType)()
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
CRPCCommand(const char *category, const char *name, rpcfn_type fn, std::initializer_list< const char * > args)
Simplified constructor taking plain rpcfn_type function pointer.
std::function< bool(const JSONRPCRequest &request, UniValue &result, bool last_handler)> Actor
RPC method handler reading request and assigning result.
void RPCSetTimerInterface(RPCTimerInterface *iface)
Set the factory function for timers.
std::vector< std::string > argNames
bool IsDeprecatedRPCEnabled(const std::string &method)
int RPCSerializationFlags()
virtual ~RPCTimerInterface()
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
CRPCCommand(std::string category, std::string name_in, RpcMethodFnType fn, std::vector< std::string > args_in)
Simplified constructor taking plain RpcMethodFnType function pointer.
Opaque base class for timers returned by NewTimerFunc.
void OnStarted(std::function< void()> slot)
std::map< std::string, std::vector< const CRPCCommand * > > mapCommands
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
std::string JSONRPCExecBatch(const JSONRPCRequest &jreq, const UniValue &vReq)
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
UniValue(* rpcfn_type)(const JSONRPCRequest &jsonRequest)
bool RPCIsInWarmup(std::string *outStatus)