MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getrpcinfo

Function getrpcinfo

src/rpc/server.cpp:192–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192static 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
238static const CRPCCommand vRPCCommands[]{
239 /* Overall control/query calls */

Callers

nothing calls this directly

Calls 5

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
pushKVMethod · 0.80
utf8stringMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected