| 71 | }; |
| 72 | |
| 73 | UniValue 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 | |
| 102 | void RPCServer::RegisterCommand(std::unique_ptr<RPCCommand> command) { |
| 103 | if (command != nullptr) { |