@@ -46,7 +46,7 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
46
46
if (!node.connman )
47
47
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
48
48
49
- return (int )g_rpc_node-> connman ->GetNodeCount (CConnman::CONNECTIONS_ALL);
49
+ return (int )node. connman ->GetNodeCount (CConnman::CONNECTIONS_ALL);
50
50
}
51
51
52
52
static UniValue ping (const JSONRPCRequest& request)
@@ -68,7 +68,7 @@ static UniValue ping(const JSONRPCRequest& request)
68
68
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
69
69
70
70
// 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) {
72
72
pnode->fPingQueued = true ;
73
73
});
74
74
return NullUniValue;
@@ -146,7 +146,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
146
146
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
147
147
148
148
std::vector<CNodeStats> vstats;
149
- g_rpc_node-> connman ->GetNodeStats (vstats);
149
+ node. connman ->GetNodeStats (vstats);
150
150
151
151
UniValue ret (UniValue::VARR);
152
152
@@ -260,18 +260,18 @@ static UniValue addnode(const JSONRPCRequest& request)
260
260
if (strCommand == " onetry" )
261
261
{
262
262
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 );
264
264
return NullUniValue;
265
265
}
266
266
267
267
if (strCommand == " add" )
268
268
{
269
- if (!g_rpc_node-> connman ->AddNode (strNode))
269
+ if (!node. connman ->AddNode (strNode))
270
270
throw JSONRPCError (RPC_CLIENT_NODE_ALREADY_ADDED, " Error: Node already added" );
271
271
}
272
272
else if (strCommand == " remove" )
273
273
{
274
- if (!g_rpc_node-> connman ->RemoveAddedNode (strNode))
274
+ if (!node. connman ->RemoveAddedNode (strNode))
275
275
throw JSONRPCError (RPC_CLIENT_NODE_NOT_ADDED, " Error: Node has not been added." );
276
276
}
277
277
@@ -307,11 +307,11 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
307
307
308
308
if (!address_arg.isNull () && id_arg.isNull ()) {
309
309
/* handle disconnect-by-address */
310
- success = g_rpc_node-> connman ->DisconnectNode (address_arg.get_str ());
310
+ success = node. connman ->DisconnectNode (address_arg.get_str ());
311
311
} else if (!id_arg.isNull () && (address_arg.isNull () || (address_arg.isStr () && address_arg.get_str ().empty ()))) {
312
312
/* handle disconnect-by-id */
313
313
NodeId nodeid = (NodeId) id_arg.get_int64 ();
314
- success = g_rpc_node-> connman ->DisconnectNode (nodeid);
314
+ success = node. connman ->DisconnectNode (nodeid);
315
315
} else {
316
316
throw JSONRPCError (RPC_INVALID_PARAMS, " Only one of address and nodeid should be provided." );
317
317
}
@@ -359,7 +359,7 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
359
359
if (!node.connman )
360
360
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
361
361
362
- std::vector<AddedNodeInfo> vInfo = g_rpc_node-> connman ->GetAddedNodeInfo ();
362
+ std::vector<AddedNodeInfo> vInfo = node. connman ->GetAddedNodeInfo ();
363
363
364
364
if (!request.params [0 ].isNull ()) {
365
365
bool found = false ;
@@ -428,17 +428,17 @@ static UniValue getnettotals(const JSONRPCRequest& request)
428
428
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
429
429
430
430
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 ());
433
433
obj.pushKV (" timemillis" , GetTimeMillis ());
434
434
435
435
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 ());
442
442
obj.pushKV (" uploadtarget" , outboundLimit);
443
443
return obj;
444
444
}
@@ -522,15 +522,15 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
522
522
obj.pushKV (" protocolversion" ,PROTOCOL_VERSION);
523
523
NodeContext& node = EnsureNodeContext (request.context );
524
524
if (node.connman ) {
525
- ServiceFlags services = g_rpc_node-> connman ->GetLocalServices ();
525
+ ServiceFlags services = node. connman ->GetLocalServices ();
526
526
obj.pushKV (" localservices" , strprintf (" %016x" , services));
527
527
obj.pushKV (" localservicesnames" , GetServicesNames (services));
528
528
}
529
529
obj.pushKV (" localrelay" , g_relay_txes);
530
530
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));
534
534
}
535
535
obj.pushKV (" networks" , GetNetworksInfo ());
536
536
obj.pushKV (" relayfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ()));
@@ -600,7 +600,7 @@ static UniValue setban(const JSONRPCRequest& request)
600
600
601
601
if (strCommand == " add" )
602
602
{
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)) {
604
604
throw JSONRPCError (RPC_CLIENT_NODE_ALREADY_ADDED, " Error: IP/Subnet already banned" );
605
605
}
606
606
@@ -613,20 +613,20 @@ static UniValue setban(const JSONRPCRequest& request)
613
613
absolute = true ;
614
614
615
615
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);
619
619
}
620
620
} 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);
624
624
}
625
625
}
626
626
}
627
627
else if (strCommand == " remove" )
628
628
{
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) )) {
630
630
throw JSONRPCError (RPC_CLIENT_INVALID_IP_OR_SUBNET, " Error: Unban failed. Requested address/subnet was not previously banned." );
631
631
}
632
632
}
@@ -660,7 +660,7 @@ static UniValue listbanned(const JSONRPCRequest& request)
660
660
}
661
661
662
662
banmap_t banMap;
663
- g_rpc_node-> banman ->GetBanned (banMap);
663
+ node. banman ->GetBanned (banMap);
664
664
665
665
UniValue bannedAddresses (UniValue::VARR);
666
666
for (const auto & entry : banMap)
@@ -694,7 +694,7 @@ static UniValue clearbanned(const JSONRPCRequest& request)
694
694
throw JSONRPCError (RPC_DATABASE_ERROR, " Error: Ban database not loaded" );
695
695
}
696
696
697
- g_rpc_node-> banman ->ClearBanned ();
697
+ node. banman ->ClearBanned ();
698
698
699
699
return NullUniValue;
700
700
}
@@ -715,9 +715,9 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
715
715
throw JSONRPCError (RPC_CLIENT_P2P_DISABLED, " Error: Peer-to-peer functionality missing or disabled" );
716
716
}
717
717
718
- g_rpc_node-> connman ->SetNetworkActive (request.params [0 ].get_bool ());
718
+ node. connman ->SetNetworkActive (request.params [0 ].get_bool ());
719
719
720
- return g_rpc_node-> connman ->GetNetworkActive ();
720
+ return node. connman ->GetNetworkActive ();
721
721
}
722
722
723
723
static UniValue getnodeaddresses (const JSONRPCRequest& request)
@@ -757,7 +757,7 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
757
757
}
758
758
}
759
759
// returns a shuffled list of CAddress
760
- std::vector<CAddress> vAddr = g_rpc_node-> connman ->GetAddresses ();
760
+ std::vector<CAddress> vAddr = node. connman ->GetAddresses ();
761
761
UniValue ret (UniValue::VARR);
762
762
763
763
int address_return_count = std::min<int >(count, vAddr.size ());
0 commit comments