| 190 | } |
| 191 | |
| 192 | static RPCMethod getrpcinfo() |
| 193 | { |
| 194 | return RPCMethod{ |
| 195 | "getrpcinfo", |
| 196 | "Returns details of the RPC server.\n", |
| 197 | {}, |
| 198 | RPCResult{ |
| 199 | RPCResult::Type::OBJ, "", "", |
| 200 | { |
| 201 | {RPCResult::Type::ARR, "active_commands", "All active commands", |
| 202 | { |
| 203 | {RPCResult::Type::OBJ, "", "Information about an active command", |
| 204 | { |
| 205 | {RPCResult::Type::STR, "method", "The name of the RPC command"}, |
| 206 | {RPCResult::Type::NUM, "duration", "The running time in microseconds"}, |
| 207 | }}, |
| 208 | }}, |
| 209 | {RPCResult::Type::STR, "logpath", "The complete file path to the debug log"}, |
| 210 | } |
| 211 | }, |
| 212 | RPCExamples{ |
| 213 | HelpExampleCli("getrpcinfo", "") |
| 214 | + HelpExampleRpc("getrpcinfo", "")}, |
| 215 | [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue |
| 216 | { |
| 217 | LOCK(g_rpc_server_info.mutex); |
| 218 | UniValue active_commands(UniValue::VARR); |
| 219 | for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands) { |
| 220 | UniValue entry(UniValue::VOBJ); |
| 221 | entry.pushKV("method", info.method); |
| 222 | entry.pushKV("duration", Ticks<std::chrono::microseconds>(SteadyClock::now() - info.start)); |
| 223 | active_commands.push_back(std::move(entry)); |
| 224 | } |
| 225 | |
| 226 | UniValue result(UniValue::VOBJ); |
| 227 | result.pushKV("active_commands", std::move(active_commands)); |
| 228 | |
| 229 | const std::string path = LogInstance().m_file_path.utf8string(); |
| 230 | UniValue log_path(UniValue::VSTR, path); |
| 231 | result.pushKV("logpath", std::move(log_path)); |
| 232 | |
| 233 | return result; |
| 234 | } |
| 235 | }; |
| 236 | } |
| 237 | |
| 238 | static const CRPCCommand vRPCCommands[]{ |
| 239 | /* Overall control/query calls */ |
nothing calls this directly
no test coverage detected