Bitcoin ABC  0.24.7
P2P Digital Currency
Classes | Functions | Variables
server.cpp File Reference
#include <rpc/server.h>
#include <config.h>
#include <rpc/util.h>
#include <shutdown.h>
#include <sync.h>
#include <util/strencodings.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/signals2/signal.hpp>
#include <cassert>
#include <memory>
#include <mutex>
#include <set>
#include <unordered_map>
Include dependency graph for server.cpp:

Go to the source code of this file.

Classes

struct  RPCCommandExecutionInfo
 
struct  RPCServerInfo
 
struct  RPCCommandExecution
 
struct  CRPCSignals
 

Functions

static bool fRPCInWarmup GUARDED_BY (g_rpc_warmup_mutex) = "RPC server started"
 
static std::map< std::string, std::unique_ptr< RPCTimerBase > > deadlineTimers GUARDED_BY (g_deadline_timers_mutex)
 
static bool ExecuteCommand (const Config &config, const CRPCCommand &command, const JSONRPCRequest &request, UniValue &result, bool last_handler)
 
static RPCHelpMan help ()
 
static RPCHelpMan stop ()
 
static RPCHelpMan uptime ()
 
static RPCHelpMan getrpcinfo ()
 
void StartRPC ()
 
void InterruptRPC ()
 
void StopRPC ()
 
bool IsRPCRunning ()
 Query whether RPC is running. More...
 
void RpcInterruptionPoint ()
 Throw JSONRPCError if RPC is not running. More...
 
void SetRPCWarmupStatus (const std::string &newStatus)
 Set the RPC warmup status. More...
 
void SetRPCWarmupFinished ()
 Mark warmup as done. More...
 
bool RPCIsInWarmup (std::string *outStatus)
 Returns the current warmup state. More...
 
bool IsDeprecatedRPCEnabled (const ArgsManager &args, const std::string &method)
 
static UniValue JSONRPCExecOne (const Config &config, RPCServer &rpcServer, JSONRPCRequest jreq, const UniValue &req)
 
std::string JSONRPCExecBatch (const Config &config, RPCServer &rpcServer, const JSONRPCRequest &jreq, const UniValue &vReq)
 
static JSONRPCRequest transformNamedArguments (const JSONRPCRequest &in, const std::vector< std::string > &argNames)
 Process named arguments into a vector of positional arguments, based on the passed-in specification for the RPC call's arguments. More...
 
void RPCSetTimerInterfaceIfUnset (RPCTimerInterface *iface)
 Set the factory function for timer, but only, if unset. More...
 
void RPCSetTimerInterface (RPCTimerInterface *iface)
 Set the factory function for timers. More...
 
void RPCUnsetTimerInterface (RPCTimerInterface *iface)
 Unset factory function for timers. More...
 
void RPCRunLater (const std::string &name, std::function< void()> func, int64_t nSeconds)
 Run func nSeconds from now. More...
 
int RPCSerializationFlags ()
 Retrieves any serialization flags requested in command line argument. More...
 

Variables

static Mutex g_rpc_warmup_mutex
 
static std::atomic< bool > g_rpc_running {false}
 
static RPCTimerInterfacetimerInterface = nullptr
 
static Mutex g_deadline_timers_mutex
 
static RPCServerInfo g_rpc_server_info
 
static struct CRPCSignals g_rpcSignals
 
static const CRPCCommand vRPCCommands []
 
CRPCTable tableRPC
 

Function Documentation

◆ ExecuteCommand()

static bool ExecuteCommand ( const Config config,
const CRPCCommand command,
const JSONRPCRequest request,
UniValue result,
bool  last_handler 
)
static

Definition at line 513 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getrpcinfo()

static RPCHelpMan getrpcinfo ( )
static

Definition at line 248 of file server.cpp.

Here is the call graph for this function:

◆ GUARDED_BY() [1/2]

static std::map<std::string, std::unique_ptr<RPCTimerBase> > deadlineTimers GUARDED_BY ( g_deadline_timers_mutex  )
static

◆ GUARDED_BY() [2/2]

static std::string rpcWarmupStatus GUARDED_BY ( g_rpc_warmup_mutex  ) = "RPC server started"
static

◆ help()

static RPCHelpMan help ( )
static

Definition at line 177 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InterruptRPC()

void InterruptRPC ( )

Definition at line 345 of file server.cpp.

Here is the caller graph for this function:

◆ IsDeprecatedRPCEnabled()

bool IsDeprecatedRPCEnabled ( const ArgsManager args,
const std::string &  method 
)

Definition at line 398 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsRPCRunning()

bool IsRPCRunning ( )

Query whether RPC is running.

Definition at line 369 of file server.cpp.

Here is the caller graph for this function:

◆ JSONRPCExecBatch()

std::string JSONRPCExecBatch ( const Config config,
RPCServer rpcServer,
const JSONRPCRequest jreq,
const UniValue vReq 
)

Definition at line 426 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ JSONRPCExecOne()

static UniValue JSONRPCExecOne ( const Config config,
RPCServer rpcServer,
JSONRPCRequest  jreq,
const UniValue req 
)
static

Definition at line 407 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RpcInterruptionPoint()

void RpcInterruptionPoint ( )

Throw JSONRPCError if RPC is not running.

Definition at line 373 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RPCIsInWarmup()

bool RPCIsInWarmup ( std::string *  outStatus)

Returns the current warmup state.

Definition at line 390 of file server.cpp.

Here is the caller graph for this function:

◆ RPCRunLater()

void RPCRunLater ( const std::string &  name,
std::function< void()>  func,
int64_t  nSeconds 
)

Run func nSeconds from now.

Overrides previous timer <name> (if any).

Definition at line 555 of file server.cpp.

Here is the call graph for this function:

◆ RPCSerializationFlags()

int RPCSerializationFlags ( )

Retrieves any serialization flags requested in command line argument.

Definition at line 570 of file server.cpp.

Here is the caller graph for this function:

◆ RPCSetTimerInterface()

void RPCSetTimerInterface ( RPCTimerInterface iface)

Set the factory function for timers.

Definition at line 545 of file server.cpp.

Here is the caller graph for this function:

◆ RPCSetTimerInterfaceIfUnset()

void RPCSetTimerInterfaceIfUnset ( RPCTimerInterface iface)

Set the factory function for timer, but only, if unset.

Definition at line 539 of file server.cpp.

◆ RPCUnsetTimerInterface()

void RPCUnsetTimerInterface ( RPCTimerInterface iface)

Unset factory function for timers.

Definition at line 549 of file server.cpp.

Here is the caller graph for this function:

◆ SetRPCWarmupFinished()

void SetRPCWarmupFinished ( )

Mark warmup as done.

RPC calls will be processed from now on.

Definition at line 384 of file server.cpp.

Here is the caller graph for this function:

◆ SetRPCWarmupStatus()

void SetRPCWarmupStatus ( const std::string &  newStatus)

Set the RPC warmup status.

When this is done, all RPC calls will error out immediately with RPC_IN_WARMUP.

Definition at line 379 of file server.cpp.

Here is the caller graph for this function:

◆ StartRPC()

void StartRPC ( )

Definition at line 339 of file server.cpp.

Here is the caller graph for this function:

◆ stop()

static RPCHelpMan stop ( )
static

Definition at line 199 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopRPC()

void StopRPC ( )

Definition at line 356 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transformNamedArguments()

static JSONRPCRequest transformNamedArguments ( const JSONRPCRequest in,
const std::vector< std::string > &  argNames 
)
inlinestatic

Process named arguments into a vector of positional arguments, based on the passed-in specification for the RPC call's arguments.

Definition at line 441 of file server.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uptime()

static RPCHelpMan uptime ( )
static

Definition at line 233 of file server.cpp.

Here is the call graph for this function:

Variable Documentation

◆ g_deadline_timers_mutex

Mutex g_deadline_timers_mutex
static

Definition at line 33 of file server.cpp.

◆ g_rpc_running

std::atomic<bool> g_rpc_running {false}
static

Definition at line 26 of file server.cpp.

◆ g_rpc_server_info

RPCServerInfo g_rpc_server_info
static

Definition at line 50 of file server.cpp.

◆ g_rpc_warmup_mutex

Mutex g_rpc_warmup_mutex
static

Definition at line 25 of file server.cpp.

◆ g_rpcSignals

struct CRPCSignals g_rpcSignals
static

◆ tableRPC

CRPCTable tableRPC

Definition at line 574 of file server.cpp.

◆ timerInterface

RPCTimerInterface* timerInterface = nullptr
static

Definition at line 31 of file server.cpp.

◆ vRPCCommands

const CRPCCommand vRPCCommands[]
static
Initial value:
= {
{ "control", "getrpcinfo", getrpcinfo, {} },
{ "control", "help", help, {"command"} },
{ "control", "stop", stop, {"wait"} },
{ "control", "uptime", uptime, {} },
}

Definition at line 301 of file server.cpp.

help
static RPCHelpMan help()
Definition: server.cpp:177
stop
static RPCHelpMan stop()
Definition: server.cpp:199
getrpcinfo
static RPCHelpMan getrpcinfo()
Definition: server.cpp:248
uptime
static RPCHelpMan uptime()
Definition: server.cpp:233