@@ -401,6 +401,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
401401 " \" localrelay\" : true|false, (bool) true if transaction relay is requested from peers\n "
402402 " \" timeoffset\" : xxxxx, (numeric) the time offset\n "
403403 " \" connections\" : xxxxx, (numeric) the number of connections\n "
404+ " \" networkactive\" : x, (numeric) the number of connections\n "
404405 " \" networks\" : [ (array) information per network\n "
405406 " {\n "
406407 " \" name\" : \" xxx\" , (string) network (ipv4, ipv6 or onion)\n "
@@ -435,8 +436,10 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
435436 obj.push_back (Pair (" localservices" , strprintf (" %016x" , g_connman->GetLocalServices ())));
436437 obj.push_back (Pair (" localrelay" , fRelayTxes ));
437438 obj.push_back (Pair (" timeoffset" , GetTimeOffset ()));
438- if (g_connman)
439+ if (g_connman) {
440+ obj.push_back (Pair (" networkactive" , (int )g_connman->GetNetworkActive ()));
439441 obj.push_back (Pair (" connections" , (int )g_connman->GetNodeCount (CConnman::CONNECTIONS_ALL)));
442+ }
440443 obj.push_back (Pair (" networks" , GetNetworksInfo ()));
441444 obj.push_back (Pair (" relayfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ())));
442445 UniValue localAddresses (UniValue::VARR);
@@ -571,20 +574,20 @@ UniValue clearbanned(const UniValue& params, bool fHelp)
571574 return NullUniValue;
572575}
573576
574- UniValue togglenetwork (const JSONRPCRequest& request)
577+ UniValue setnetworkactive (const JSONRPCRequest& request)
575578{
576- if (request.fHelp || request.params .size () != 0 ) {
579+ if (request.fHelp || request.params .size () != 1 ) {
577580 throw runtime_error (
578- " togglenetwork \n "
579- " Toggle all network activity temporarily."
581+ " setnetworkactive \" true|false \" \n"
582+ " Disable/Re-Enable all network activity temporarily."
580583 );
581584 }
582585
583586 if (!g_connman) {
584587 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
585588 }
586589
587- g_connman->SetNetworkActive (!g_connman-> GetNetworkActive ());
590+ g_connman->SetNetworkActive (request. params [ 0 ]. get_bool ());
588591
589592 return g_connman->GetNetworkActive ();
590593}
@@ -603,7 +606,7 @@ static const CRPCCommand commands[] =
603606 { " network" , " setban" , &setban, true },
604607 { " network" , " listbanned" , &listbanned, true },
605608 { " network" , " clearbanned" , &clearbanned, true },
606- { " network" , " togglenetwork " , &togglenetwork, true , },
609+ { " network" , " setnetworkactive " , &setnetworkactive, true , },
607610};
608611
609612void RegisterNetRPCCommands (CRPCTable &t)
0 commit comments