| 204 | } |
| 205 | |
| 206 | static RPCHelpMan getrpcinfo() |
| 207 | { |
| 208 | return RPCHelpMan{"getrpcinfo", |
| 209 | "\nReturns details of the RPC server.\n", |
| 210 | {}, |
| 211 | RPCResult{ |
| 212 | RPCResult::Type::OBJ, "", "", |
| 213 | { |
| 214 | {RPCResult::Type::ARR, "active_commands", "All active commands", |
| 215 | { |
| 216 | {RPCResult::Type::OBJ, "", "Information about an active command", |
| 217 | { |
| 218 | {RPCResult::Type::STR, "method", "The name of the RPC command"}, |
| 219 | {RPCResult::Type::NUM, "duration", "The running time in microseconds"}, |
| 220 | }}, |
| 221 | }}, |
| 222 | {RPCResult::Type::STR, "logpath", "The complete file path to the debug log"}, |
| 223 | } |
| 224 | }, |
| 225 | RPCExamples{ |
| 226 | HelpExampleCli("getrpcinfo", "") |
| 227 | + HelpExampleRpc("getrpcinfo", "")}, |
| 228 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 229 | { |
| 230 | LOCK(g_rpc_server_info.mutex); |
| 231 | UniValue active_commands(UniValue::VARR); |
| 232 | for (const RPCCommandExecutionInfo& info : g_rpc_server_info.active_commands) { |
| 233 | UniValue entry(UniValue::VOBJ); |
| 234 | entry.pushKV("method", info.method); |
| 235 | entry.pushKV("duration", GetTimeMicros() - info.start); |
| 236 | active_commands.push_back(entry); |
| 237 | } |
| 238 | |
| 239 | UniValue result(UniValue::VOBJ); |
| 240 | result.pushKV("active_commands", active_commands); |
| 241 | |
| 242 | const std::string path = LogInstance().m_file_path.u8string(); |
| 243 | UniValue log_path(UniValue::VSTR, path); |
| 244 | result.pushKV("logpath", log_path); |
| 245 | |
| 246 | return result; |
| 247 | } |
| 248 | }; |
| 249 | } |
| 250 | |
| 251 | // clang-format off |
| 252 | static const CRPCCommand vRPCCommands[] = |
nothing calls this directly
no test coverage detected