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;
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)>;
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;
188 #endif // BITCOIN_RPC_SERVER_H
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
std::vector< std::string > listCommands() const
Returns a list of registered commands.
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.
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
void SetRPCWarmupFinished()
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
void OnStopped(std::function< void()> slot)
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.
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
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()
UniValue(* rpcfn_type)(const JSONRPCRequest &jsonRequest)
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
virtual RPCTimerBase * NewTimer(std::function< void()> &func, int64_t millis)=0
Factory function for timers.
std::string help(const std::string &name, const JSONRPCRequest &helpreq) const
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.
virtual const char * Name()=0
Implementation name.
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)
RPCHelpMan(* RpcMethodFnType)()
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
bool RPCIsInWarmup(std::string *outStatus)