mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
RPC: Add "togglenetwork" method to toggle network activity temporarily
RPC command "togglenetwork" toggles network and returns new state after command. RPC command "getinfo" returns "networkactive" field in output.
This commit is contained in:
committed by
Luke Dashjr
parent
7c9a98aac8
commit
e38993bb36
@@ -571,6 +571,24 @@ UniValue clearbanned(const UniValue& params, bool fHelp)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
UniValue togglenetwork(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0) {
|
||||
throw runtime_error(
|
||||
"togglenetwork\n"
|
||||
"Toggle all network activity temporarily."
|
||||
);
|
||||
}
|
||||
|
||||
if (!g_connman) {
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
}
|
||||
|
||||
g_connman->SetNetworkActive(!g_connman->GetNetworkActive());
|
||||
|
||||
return g_connman->GetNetworkActive();
|
||||
}
|
||||
|
||||
static const CRPCCommand commands[] =
|
||||
{ // category name actor (function) okSafeMode
|
||||
// --------------------- ------------------------ ----------------------- ----------
|
||||
@@ -585,6 +603,7 @@ static const CRPCCommand commands[] =
|
||||
{ "network", "setban", &setban, true },
|
||||
{ "network", "listbanned", &listbanned, true },
|
||||
{ "network", "clearbanned", &clearbanned, true },
|
||||
{ "network", "togglenetwork", &togglenetwork, true, },
|
||||
};
|
||||
|
||||
void RegisterNetRPCCommands(CRPCTable &t)
|
||||
|
||||
Reference in New Issue
Block a user