MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / ExecuteCommand

Method ExecuteCommand

src/rpc/server.cpp:73–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71};
72
73UniValue RPCServer::ExecuteCommand(const Config &config,
74 const JSONRPCRequest &request) const {
75 // Return immediately if in warmup
76 // This is retained from the old RPC implementation because a lot of state
77 // is set during warmup that RPC commands may depend on. This can be
78 // safely removed once global variable usage has been eliminated.
79 {
80 LOCK(g_rpc_warmup_mutex);
81 if (fRPCInWarmup) {
82 throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
83 }
84 }
85
86 std::string commandName = request.strMethod;
87 {
88 auto commandsReadView = commands.getReadView();
89 auto iter = commandsReadView->find(commandName);
90 if (iter != commandsReadView.end()) {
91 return iter->second.get()->Execute(request);
92 }
93 }
94
95 // TODO Remove the below call to tableRPC.execute() and only call it for
96 // context-free RPC commands via an implementation of RPCCommand.
97
98 // Check if context-free RPC method is valid and execute it
99 return tableRPC.execute(config, request);
100}
101
102void RPCServer::RegisterCommand(std::unique_ptr<RPCCommand> command) {
103 if (command != nullptr) {

Callers 3

ProcessHTTPRequestMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
JSONRPCExecOneFunction · 0.80

Calls 7

JSONRPCErrorFunction · 0.85
getReadViewMethod · 0.80
getMethod · 0.65
executeMethod · 0.65
findMethod · 0.45
endMethod · 0.45
ExecuteMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64