mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-08-04 05:54:48 +02:00
scripted-diff: Remove g_rpc_node references
This commit does not change behavior -BEGIN VERIFY SCRIPT- git grep -l g_rpc_node | xargs sed -i 's/g_rpc_node->/node./g' -END VERIFY SCRIPT-
This commit is contained in:
parent
6fca33b2ed
commit
ccb5059ee8
@ -639,7 +639,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
if (g_rpc_node->connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
|
if (node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
|
||||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");
|
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");
|
||||||
|
|
||||||
if (::ChainstateActive().IsInitialBlockDownload())
|
if (::ChainstateActive().IsInitialBlockDownload())
|
||||||
|
@ -46,7 +46,7 @@ static UniValue getconnectioncount(const JSONRPCRequest& request)
|
|||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
return (int)g_rpc_node->connman->GetNodeCount(CConnman::CONNECTIONS_ALL);
|
return (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UniValue ping(const JSONRPCRequest& request)
|
static UniValue ping(const JSONRPCRequest& request)
|
||||||
@ -68,7 +68,7 @@ static UniValue ping(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
// Request that each node send a ping during next message processing pass
|
// Request that each node send a ping during next message processing pass
|
||||||
g_rpc_node->connman->ForEachNode([](CNode* pnode) {
|
node.connman->ForEachNode([](CNode* pnode) {
|
||||||
pnode->fPingQueued = true;
|
pnode->fPingQueued = true;
|
||||||
});
|
});
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
@ -146,7 +146,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
std::vector<CNodeStats> vstats;
|
std::vector<CNodeStats> vstats;
|
||||||
g_rpc_node->connman->GetNodeStats(vstats);
|
node.connman->GetNodeStats(vstats);
|
||||||
|
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
@ -260,18 +260,18 @@ static UniValue addnode(const JSONRPCRequest& request)
|
|||||||
if (strCommand == "onetry")
|
if (strCommand == "onetry")
|
||||||
{
|
{
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
g_rpc_node->connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), false, false, true);
|
node.connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), false, false, true);
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strCommand == "add")
|
if (strCommand == "add")
|
||||||
{
|
{
|
||||||
if(!g_rpc_node->connman->AddNode(strNode))
|
if(!node.connman->AddNode(strNode))
|
||||||
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
|
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
|
||||||
}
|
}
|
||||||
else if(strCommand == "remove")
|
else if(strCommand == "remove")
|
||||||
{
|
{
|
||||||
if(!g_rpc_node->connman->RemoveAddedNode(strNode))
|
if(!node.connman->RemoveAddedNode(strNode))
|
||||||
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
|
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,11 +307,11 @@ static UniValue disconnectnode(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
if (!address_arg.isNull() && id_arg.isNull()) {
|
if (!address_arg.isNull() && id_arg.isNull()) {
|
||||||
/* handle disconnect-by-address */
|
/* handle disconnect-by-address */
|
||||||
success = g_rpc_node->connman->DisconnectNode(address_arg.get_str());
|
success = node.connman->DisconnectNode(address_arg.get_str());
|
||||||
} else if (!id_arg.isNull() && (address_arg.isNull() || (address_arg.isStr() && address_arg.get_str().empty()))) {
|
} else if (!id_arg.isNull() && (address_arg.isNull() || (address_arg.isStr() && address_arg.get_str().empty()))) {
|
||||||
/* handle disconnect-by-id */
|
/* handle disconnect-by-id */
|
||||||
NodeId nodeid = (NodeId) id_arg.get_int64();
|
NodeId nodeid = (NodeId) id_arg.get_int64();
|
||||||
success = g_rpc_node->connman->DisconnectNode(nodeid);
|
success = node.connman->DisconnectNode(nodeid);
|
||||||
} else {
|
} else {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMS, "Only one of address and nodeid should be provided.");
|
throw JSONRPCError(RPC_INVALID_PARAMS, "Only one of address and nodeid should be provided.");
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ static UniValue getaddednodeinfo(const JSONRPCRequest& request)
|
|||||||
if(!node.connman)
|
if(!node.connman)
|
||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
std::vector<AddedNodeInfo> vInfo = g_rpc_node->connman->GetAddedNodeInfo();
|
std::vector<AddedNodeInfo> vInfo = node.connman->GetAddedNodeInfo();
|
||||||
|
|
||||||
if (!request.params[0].isNull()) {
|
if (!request.params[0].isNull()) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -428,17 +428,17 @@ static UniValue getnettotals(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("totalbytesrecv", g_rpc_node->connman->GetTotalBytesRecv());
|
obj.pushKV("totalbytesrecv", node.connman->GetTotalBytesRecv());
|
||||||
obj.pushKV("totalbytessent", g_rpc_node->connman->GetTotalBytesSent());
|
obj.pushKV("totalbytessent", node.connman->GetTotalBytesSent());
|
||||||
obj.pushKV("timemillis", GetTimeMillis());
|
obj.pushKV("timemillis", GetTimeMillis());
|
||||||
|
|
||||||
UniValue outboundLimit(UniValue::VOBJ);
|
UniValue outboundLimit(UniValue::VOBJ);
|
||||||
outboundLimit.pushKV("timeframe", g_rpc_node->connman->GetMaxOutboundTimeframe());
|
outboundLimit.pushKV("timeframe", node.connman->GetMaxOutboundTimeframe());
|
||||||
outboundLimit.pushKV("target", g_rpc_node->connman->GetMaxOutboundTarget());
|
outboundLimit.pushKV("target", node.connman->GetMaxOutboundTarget());
|
||||||
outboundLimit.pushKV("target_reached", g_rpc_node->connman->OutboundTargetReached(false));
|
outboundLimit.pushKV("target_reached", node.connman->OutboundTargetReached(false));
|
||||||
outboundLimit.pushKV("serve_historical_blocks", !g_rpc_node->connman->OutboundTargetReached(true));
|
outboundLimit.pushKV("serve_historical_blocks", !node.connman->OutboundTargetReached(true));
|
||||||
outboundLimit.pushKV("bytes_left_in_cycle", g_rpc_node->connman->GetOutboundTargetBytesLeft());
|
outboundLimit.pushKV("bytes_left_in_cycle", node.connman->GetOutboundTargetBytesLeft());
|
||||||
outboundLimit.pushKV("time_left_in_cycle", g_rpc_node->connman->GetMaxOutboundTimeLeftInCycle());
|
outboundLimit.pushKV("time_left_in_cycle", node.connman->GetMaxOutboundTimeLeftInCycle());
|
||||||
obj.pushKV("uploadtarget", outboundLimit);
|
obj.pushKV("uploadtarget", outboundLimit);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -522,15 +522,15 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
|||||||
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
obj.pushKV("protocolversion",PROTOCOL_VERSION);
|
||||||
NodeContext& node = EnsureNodeContext(request.context);
|
NodeContext& node = EnsureNodeContext(request.context);
|
||||||
if (node.connman) {
|
if (node.connman) {
|
||||||
ServiceFlags services = g_rpc_node->connman->GetLocalServices();
|
ServiceFlags services = node.connman->GetLocalServices();
|
||||||
obj.pushKV("localservices", strprintf("%016x", services));
|
obj.pushKV("localservices", strprintf("%016x", services));
|
||||||
obj.pushKV("localservicesnames", GetServicesNames(services));
|
obj.pushKV("localservicesnames", GetServicesNames(services));
|
||||||
}
|
}
|
||||||
obj.pushKV("localrelay", g_relay_txes);
|
obj.pushKV("localrelay", g_relay_txes);
|
||||||
obj.pushKV("timeoffset", GetTimeOffset());
|
obj.pushKV("timeoffset", GetTimeOffset());
|
||||||
if (g_rpc_node->connman) {
|
if (node.connman) {
|
||||||
obj.pushKV("networkactive", g_rpc_node->connman->GetNetworkActive());
|
obj.pushKV("networkactive", node.connman->GetNetworkActive());
|
||||||
obj.pushKV("connections", (int)g_rpc_node->connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
|
obj.pushKV("connections", (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
|
||||||
}
|
}
|
||||||
obj.pushKV("networks", GetNetworksInfo());
|
obj.pushKV("networks", GetNetworksInfo());
|
||||||
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
|
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
|
||||||
@ -600,7 +600,7 @@ static UniValue setban(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
if (strCommand == "add")
|
if (strCommand == "add")
|
||||||
{
|
{
|
||||||
if (isSubnet ? g_rpc_node->banman->IsBanned(subNet) : g_rpc_node->banman->IsBanned(netAddr)) {
|
if (isSubnet ? node.banman->IsBanned(subNet) : node.banman->IsBanned(netAddr)) {
|
||||||
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned");
|
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,20 +613,20 @@ static UniValue setban(const JSONRPCRequest& request)
|
|||||||
absolute = true;
|
absolute = true;
|
||||||
|
|
||||||
if (isSubnet) {
|
if (isSubnet) {
|
||||||
g_rpc_node->banman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute);
|
node.banman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute);
|
||||||
if (g_rpc_node->connman) {
|
if (node.connman) {
|
||||||
g_rpc_node->connman->DisconnectNode(subNet);
|
node.connman->DisconnectNode(subNet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_rpc_node->banman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute);
|
node.banman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute);
|
||||||
if (g_rpc_node->connman) {
|
if (node.connman) {
|
||||||
g_rpc_node->connman->DisconnectNode(netAddr);
|
node.connman->DisconnectNode(netAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strCommand == "remove")
|
else if(strCommand == "remove")
|
||||||
{
|
{
|
||||||
if (!( isSubnet ? g_rpc_node->banman->Unban(subNet) : g_rpc_node->banman->Unban(netAddr) )) {
|
if (!( isSubnet ? node.banman->Unban(subNet) : node.banman->Unban(netAddr) )) {
|
||||||
throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Unban failed. Requested address/subnet was not previously banned.");
|
throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Unban failed. Requested address/subnet was not previously banned.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,7 +660,7 @@ static UniValue listbanned(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
banmap_t banMap;
|
banmap_t banMap;
|
||||||
g_rpc_node->banman->GetBanned(banMap);
|
node.banman->GetBanned(banMap);
|
||||||
|
|
||||||
UniValue bannedAddresses(UniValue::VARR);
|
UniValue bannedAddresses(UniValue::VARR);
|
||||||
for (const auto& entry : banMap)
|
for (const auto& entry : banMap)
|
||||||
@ -694,7 +694,7 @@ static UniValue clearbanned(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
throw JSONRPCError(RPC_DATABASE_ERROR, "Error: Ban database not loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_rpc_node->banman->ClearBanned();
|
node.banman->ClearBanned();
|
||||||
|
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
@ -715,9 +715,9 @@ static UniValue setnetworkactive(const JSONRPCRequest& request)
|
|||||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_rpc_node->connman->SetNetworkActive(request.params[0].get_bool());
|
node.connman->SetNetworkActive(request.params[0].get_bool());
|
||||||
|
|
||||||
return g_rpc_node->connman->GetNetworkActive();
|
return node.connman->GetNetworkActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
static UniValue getnodeaddresses(const JSONRPCRequest& request)
|
static UniValue getnodeaddresses(const JSONRPCRequest& request)
|
||||||
@ -757,7 +757,7 @@ static UniValue getnodeaddresses(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// returns a shuffled list of CAddress
|
// returns a shuffled list of CAddress
|
||||||
std::vector<CAddress> vAddr = g_rpc_node->connman->GetAddresses();
|
std::vector<CAddress> vAddr = node.connman->GetAddresses();
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
int address_return_count = std::min<int>(count, vAddr.size());
|
int address_return_count = std::min<int>(count, vAddr.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user