7#ifndef BITCOIN_RPC_SERVER_H
8#define BITCOIN_RPC_SERVER_H
29void OnStarted(std::function<
void()> slot);
30void OnStopped(std::function<
void()> slot);
35typedef std::map<std::string, std::unique_ptr<RPCCommand>>
RPCCommandMap;
107 virtual const char *
Name() = 0;
154 UniValue &result,
bool last_handler)>;
158 std::vector<std::pair<std::string, bool>> _args,
167 _category, _fn().m_name,
170 result = _fn().HandleRequest(config, request);
173 _fn().GetArgNames(), intptr_t(_fn)) {}
187 std::vector<std::pair<std::string, bool>>
argNames;
196 std::map<std::string, std::vector<const CRPCCommand *>>
mapCommands;
std::vector< std::pair< std::string, bool > > argNames
List of method arguments and whether they are named-only.
CRPCCommand(std::string _category, RpcMethodFnType _fn)
Simplified constructor taking plain RpcMethodFnType function pointer.
CRPCCommand(std::string _category, std::string _name, Actor _actor, std::vector< std::pair< std::string, bool > > _args, intptr_t _unique_id)
Constructor taking Actor callback supporting multiple handlers.
std::function< bool(const Config &config, const JSONRPCRequest &request, UniValue &result, bool last_handler)> Actor
RPC method handler reading request and assigning result.
std::map< std::string, std::vector< const CRPCCommand * > > mapCommands
bool removeCommand(const std::string &name, const CRPCCommand *pcmd)
std::string help(const Config &config, const std::string &name, const JSONRPCRequest &helpreq) const
std::vector< std::string > listCommands() const
Returns a list of registered commands.
UniValue execute(const Config &config, const JSONRPCRequest &request) const
Execute a method.
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
UniValue dumpArgMap(const Config &config, const JSONRPCRequest &request) const
Return all named arguments that need to be converted by the client from string to another JSON type.
Class for registering and managing all RPC calls.
RPCServer & operator=(const RPCServer &)=delete
RPCServer(const RPCServer &)=delete
UniValue ExecuteCommand(const Config &config, const JSONRPCRequest &request) const
Attempts to execute an RPC command from the given request.
RWCollection< RPCCommandMap > commands
void RegisterCommand(std::unique_ptr< RPCCommand > command)
Register an RPC command.
Opaque base class for timers returned by NewTimerFunc.
virtual ~RPCTimerInterface()
virtual RPCTimerBase * NewTimer(std::function< void()> &func, int64_t millis)=0
Factory function for timers.
virtual const char * Name()=0
Implementation name.
void OnStarted(std::function< void()> slot)
void OnStopped(std::function< void()> slot)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
void SetRPCWarmupFinished()
Mark warmup as done.
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
bool RPCIsInWarmup(std::string *outStatus)
Returns the current warmup state.
std::string JSONRPCExecBatch(const Config &config, RPCServer &rpcServer, const JSONRPCRequest &req, const UniValue &vReq)
RPCHelpMan(*)() RpcMethodFnType
bool IsRPCRunning()
Query whether RPC is running.
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
std::map< std::string, std::unique_ptr< RPCCommand > > RPCCommandMap
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
void RPCSetTimerInterface(RPCTimerInterface *iface)
Set the factory function for timers.
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.