@@ -46,7 +46,7 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
4646 if (!node.connman )
4747 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
4848
49- return (int )g_rpc_node-> connman ->GetNodeCount (CConnman::CONNECTIONS_ALL);
49+ return (int )node. connman ->GetNodeCount (CConnman::CONNECTIONS_ALL);
5050}
5151
5252static UniValue ping (const JSONRPCRequest& request)
@@ -68,7 +68,7 @@ static UniValue ping(const JSONRPCRequest& request)
6868 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
6969
7070 // Request that each node send a ping during next message processing pass
71- g_rpc_node-> connman ->ForEachNode ([](CNode* pnode) {
71+ node. connman ->ForEachNode ([](CNode* pnode) {
7272 pnode->fPingQueued = true ;
7373 });
7474 return NullUniValue;
@@ -146,7 +146,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
146146 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
147147
148148 std::vector<CNodeStats> vstats;
149- g_rpc_node-> connman ->GetNodeStats (vstats);
149+ node. connman ->GetNodeStats (vstats);
150150
151151 UniValue ret (UniValue::VARR);
152152
@@ -260,18 +260,18 @@ static UniValue addnode(const JSONRPCRequest& request)
260260 if (strCommand == " onetry" )
261261 {
262262 CAddress addr;
263- g_rpc_node-> connman ->OpenNetworkConnection (addr, false , nullptr , strNode.c_str (), false , false , true );
263+ node. connman ->OpenNetworkConnection (addr, false , nullptr , strNode.c_str (), false , false , true );
264264 return NullUniValue;
265265 }
266266
267267 if (strCommand == " add" )
268268 {
269- if (!g_rpc_node-> connman ->AddNode (strNode))
269+ if (!node. connman ->AddNode (strNode))
270270 throw JSONRPCError (RPC_CLIENT_NODE_ALREADY_ADDED, " Error: Node already added" );
271271 }
272272 else if (strCommand == " remove" )
273273 {
274- if (!g_rpc_node-> connman ->RemoveAddedNode (strNode))
274+ if (!node. connman ->RemoveAddedNode (strNode))
275275 throw JSONRPCError (RPC_CLIENT_NODE_NOT_ADDED, " Error: Node has not been added." );
276276 }
277277
@@ -307,11 +307,11 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
307307
308308 if (!address_arg.isNull () && id_arg.isNull ()) {
309309 /* handle disconnect-by-address */
310- success = g_rpc_node-> connman ->DisconnectNode (address_arg.get_str ());
310+ success = node. connman ->DisconnectNode (address_arg.get_str ());
311311 } else if (!id_arg.isNull () && (address_arg.isNull () || (address_arg.isStr () && address_arg.get_str ().empty ()))) {
312312 /* handle disconnect-by-id */
313313 NodeId nodeid = (NodeId) id_arg.get_int64 ();
314- success = g_rpc_node-> connman ->DisconnectNode (nodeid);
314+ success = node. connman ->DisconnectNode (nodeid);
315315 } else {
316316 throw JSONRPCError (RPC_INVALID_PARAMS, " Only one of address and nodeid should be provided." );
317317 }
@@ -359,7 +359,7 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
359359 if (!node.connman )
360360 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
361361
362- std::vector<AddedNodeInfo> vInfo = g_rpc_node-> connman ->GetAddedNodeInfo ();
362+ std::vector<AddedNodeInfo> vInfo = node. connman ->GetAddedNodeInfo ();
363363
364364 if (!request.params [0 ].isNull ()) {
365365 bool found = false ;
@@ -428,17 +428,17 @@ static UniValue getnettotals(const JSONRPCRequest& request)
428428 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
429429
430430 UniValue obj (UniValue::VOBJ);
431- obj.pushKV (" totalbytesrecv" , g_rpc_node-> connman ->GetTotalBytesRecv ());
432- obj.pushKV (" totalbytessent" , g_rpc_node-> connman ->GetTotalBytesSent ());
431+ obj.pushKV (" totalbytesrecv" , node. connman ->GetTotalBytesRecv ());
432+ obj.pushKV (" totalbytessent" , node. connman ->GetTotalBytesSent ());
433433 obj.pushKV (" timemillis" , GetTimeMillis ());
434434
435435 UniValue outboundLimit (UniValue::VOBJ);
436- outboundLimit.pushKV (" timeframe" , g_rpc_node-> connman ->GetMaxOutboundTimeframe ());
437- outboundLimit.pushKV (" target" , g_rpc_node-> connman ->GetMaxOutboundTarget ());
438- outboundLimit.pushKV (" target_reached" , g_rpc_node-> connman ->OutboundTargetReached (false ));
439- outboundLimit.pushKV (" serve_historical_blocks" , !g_rpc_node-> connman ->OutboundTargetReached (true ));
440- outboundLimit.pushKV (" bytes_left_in_cycle" , g_rpc_node-> connman ->GetOutboundTargetBytesLeft ());
441- outboundLimit.pushKV (" time_left_in_cycle" , g_rpc_node-> connman ->GetMaxOutboundTimeLeftInCycle ());
436+ outboundLimit.pushKV (" timeframe" , node. connman ->GetMaxOutboundTimeframe ());
437+ outboundLimit.pushKV (" target" , node. connman ->GetMaxOutboundTarget ());
438+ outboundLimit.pushKV (" target_reached" , node. connman ->OutboundTargetReached (false ));
439+ outboundLimit.pushKV (" serve_historical_blocks" , !node. connman ->OutboundTargetReached (true ));
440+ outboundLimit.pushKV (" bytes_left_in_cycle" , node. connman ->GetOutboundTargetBytesLeft ());
441+ outboundLimit.pushKV (" time_left_in_cycle" , node. connman ->GetMaxOutboundTimeLeftInCycle ());
442442 obj.pushKV (" uploadtarget" , outboundLimit);
443443 return obj;
444444}
@@ -522,15 +522,15 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
522522 obj.pushKV (" protocolversion" ,PROTOCOL_VERSION);
523523 NodeContext& node = EnsureNodeContext (request.context );
524524 if (node.connman ) {
525- ServiceFlags services = g_rpc_node-> connman ->GetLocalServices ();
525+ ServiceFlags services = node. connman ->GetLocalServices ();
526526 obj.pushKV (" localservices" , strprintf (" %016x" , services));
527527 obj.pushKV (" localservicesnames" , GetServicesNames (services));
528528 }
529529 obj.pushKV (" localrelay" , g_relay_txes);
530530 obj.pushKV (" timeoffset" , GetTimeOffset ());
531- if (g_rpc_node-> connman ) {
532- obj.pushKV (" networkactive" , g_rpc_node-> connman ->GetNetworkActive ());
533- obj.pushKV (" connections" , (int )g_rpc_node-> connman ->GetNodeCount (CConnman::CONNECTIONS_ALL));
531+ if (node. connman ) {
532+ obj.pushKV (" networkactive" , node. connman ->GetNetworkActive ());
533+ obj.pushKV (" connections" , (int )node. connman ->GetNodeCount (CConnman::CONNECTIONS_ALL));
534534 }
535535 obj.pushKV (" networks" , GetNetworksInfo ());
536536 obj.pushKV (" relayfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ()));
@@ -600,7 +600,7 @@ static UniValue setban(const JSONRPCRequest& request)
600600
601601 if (strCommand == " add" )
602602 {
603- if (isSubnet ? g_rpc_node-> banman ->IsBanned (subNet) : g_rpc_node-> banman ->IsBanned (netAddr)) {
603+ if (isSubnet ? node. banman ->IsBanned (subNet) : node. banman ->IsBanned (netAddr)) {
604604 throw JSONRPCError (RPC_CLIENT_NODE_ALREADY_ADDED, " Error: IP/Subnet already banned" );
605605 }
606606
@@ -613,20 +613,20 @@ static UniValue setban(const JSONRPCRequest& request)
613613 absolute = true ;
614614
615615 if (isSubnet) {
616- g_rpc_node-> banman ->Ban (subNet, BanReasonManuallyAdded, banTime, absolute);
617- if (g_rpc_node-> connman ) {
618- g_rpc_node-> connman ->DisconnectNode (subNet);
616+ node. banman ->Ban (subNet, BanReasonManuallyAdded, banTime, absolute);
617+ if (node. connman ) {
618+ node. connman ->DisconnectNode (subNet);
619619 }
620620 } else {
621- g_rpc_node-> banman ->Ban (netAddr, BanReasonManuallyAdded, banTime, absolute);
622- if (g_rpc_node-> connman ) {
623- g_rpc_node-> connman ->DisconnectNode (netAddr);
621+ node. banman ->Ban (netAddr, BanReasonManuallyAdded, banTime, absolute);
622+ if (node. connman ) {
623+ node. connman ->DisconnectNode (netAddr);
624624 }
625625 }
626626 }
627627 else if (strCommand == " remove" )
628628 {
629- if (!( isSubnet ? g_rpc_node-> banman ->Unban (subNet) : g_rpc_node-> banman ->Unban (netAddr) )) {
629+ if (!( isSubnet ? node. banman ->Unban (subNet) : node. banman ->Unban (netAddr) )) {
630630 throw JSONRPCError (RPC_CLIENT_INVALID_IP_OR_SUBNET, " Error: Unban failed. Requested address/subnet was not previously banned." );
631631 }
632632 }
@@ -660,7 +660,7 @@ static UniValue listbanned(const JSONRPCRequest& request)
660660 }
661661
662662 banmap_t banMap;
663- g_rpc_node-> banman ->GetBanned (banMap);
663+ node. banman ->GetBanned (banMap);
664664
665665 UniValue bannedAddresses (UniValue::VARR);
666666 for (const auto & entry : banMap)
@@ -694,7 +694,7 @@ static UniValue clearbanned(const JSONRPCRequest& request)
694694 throw JSONRPCError (RPC_DATABASE_ERROR, " Error: Ban database not loaded" );
695695 }
696696
697- g_rpc_node-> banman ->ClearBanned ();
697+ node. banman ->ClearBanned ();
698698
699699 return NullUniValue;
700700}
@@ -715,9 +715,9 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
715715 throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
716716 }
717717
718- g_rpc_node-> connman ->SetNetworkActive (request.params [0 ].get_bool ());
718+ node. connman ->SetNetworkActive (request.params [0 ].get_bool ());
719719
720- return g_rpc_node-> connman ->GetNetworkActive ();
720+ return node. connman ->GetNetworkActive ();
721721}
722722
723723static UniValue getnodeaddresses (const JSONRPCRequest& request)
@@ -757,7 +757,7 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
757757 }
758758 }
759759 // returns a shuffled list of CAddress
760- std::vector<CAddress> vAddr = g_rpc_node-> connman ->GetAddresses ();
760+ std::vector<CAddress> vAddr = node. connman ->GetAddresses ();
761761 UniValue ret (UniValue::VARR);
762762
763763 int address_return_count = std::min<int >(count, vAddr.size ());
0 commit comments