MCPcopy Create free account
hub / github.com/ElementsProject/elements / getnettotals

Function getnettotals

src/rpc/net.cpp:503–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503static RPCHelpMan getnettotals()
504{
505 return RPCHelpMan{"getnettotals",
506 "\nReturns information about network traffic, including bytes in, bytes out,\n"
507 "and current time.\n",
508 {},
509 RPCResult{
510 RPCResult::Type::OBJ, "", "",
511 {
512 {RPCResult::Type::NUM, "totalbytesrecv", "Total bytes received"},
513 {RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"},
514 {RPCResult::Type::NUM_TIME, "timemillis", "Current " + UNIX_EPOCH_TIME + " in milliseconds"},
515 {RPCResult::Type::OBJ, "uploadtarget", "",
516 {
517 {RPCResult::Type::NUM, "timeframe", "Length of the measuring timeframe in seconds"},
518 {RPCResult::Type::NUM, "target", "Target in bytes"},
519 {RPCResult::Type::BOOL, "target_reached", "True if target is reached"},
520 {RPCResult::Type::BOOL, "serve_historical_blocks", "True if serving historical blocks"},
521 {RPCResult::Type::NUM, "bytes_left_in_cycle", "Bytes left in current time cycle"},
522 {RPCResult::Type::NUM, "time_left_in_cycle", "Seconds left in current time cycle"},
523 }},
524 }
525 },
526 RPCExamples{
527 HelpExampleCli("getnettotals", "")
528 + HelpExampleRpc("getnettotals", "")
529 },
530 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
531{
532 NodeContext& node = EnsureAnyNodeContext(request.context);
533 const CConnman& connman = EnsureConnman(node);
534
535 UniValue obj(UniValue::VOBJ);
536 obj.pushKV("totalbytesrecv", connman.GetTotalBytesRecv());
537 obj.pushKV("totalbytessent", connman.GetTotalBytesSent());
538 obj.pushKV("timemillis", GetTimeMillis());
539
540 UniValue outboundLimit(UniValue::VOBJ);
541 outboundLimit.pushKV("timeframe", count_seconds(connman.GetMaxOutboundTimeframe()));
542 outboundLimit.pushKV("target", connman.GetMaxOutboundTarget());
543 outboundLimit.pushKV("target_reached", connman.OutboundTargetReached(false));
544 outboundLimit.pushKV("serve_historical_blocks", !connman.OutboundTargetReached(true));
545 outboundLimit.pushKV("bytes_left_in_cycle", connman.GetOutboundTargetBytesLeft());
546 outboundLimit.pushKV("time_left_in_cycle", count_seconds(connman.GetMaxOutboundTimeLeftInCycle()));
547 obj.pushKV("uploadtarget", outboundLimit);
548 return obj;
549},
550 };
551}
552
553static UniValue GetNetworksInfo()
554{

Callers

nothing calls this directly

Calls 12

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
GetTimeMillisFunction · 0.85
count_secondsFunction · 0.85
GetTotalBytesRecvMethod · 0.80
GetTotalBytesSentMethod · 0.80
GetMaxOutboundTargetMethod · 0.80
OutboundTargetReachedMethod · 0.80
pushKVMethod · 0.45

Tested by

no test coverage detected