| 472 | } |
| 473 | |
| 474 | UniValue CRPCTable::execute(const JSONRPCRequest &request) const |
| 475 | { |
| 476 | // Return immediately if in warmup |
| 477 | { |
| 478 | LOCK(cs_rpcWarmup); |
| 479 | if (fRPCInWarmup) |
| 480 | throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus); |
| 481 | } |
| 482 | |
| 483 | // Find method |
| 484 | const CRPCCommand *pcmd = tableRPC[request.strMethod]; |
| 485 | if (!pcmd) |
| 486 | throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); |
| 487 | |
| 488 | g_rpcSignals.PreCommand(*pcmd); |
| 489 | |
| 490 | try |
| 491 | { |
| 492 | // Execute, convert arguments to array if necessary |
| 493 | if (request.params.isObject()) { |
| 494 | return pcmd->actor(transformNamedArguments(request, pcmd->argNames)); |
| 495 | } else { |
| 496 | return pcmd->actor(request); |
| 497 | } |
| 498 | } |
| 499 | catch (const std::exception& e) |
| 500 | { |
| 501 | throw JSONRPCError(RPC_MISC_ERROR, e.what()); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | std::vector<std::string> CRPCTable::listCommands() const |
| 506 | { |
no test coverage detected