aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/net.cpp
diff options
context:
space:
mode:
authorJon Lund Steffensen <[email protected]>2013-03-26 02:38:24 +0100
committerLuke Dashjr <[email protected]>2016-10-24 10:23:58 +0000
commite38993bb36801d492cad87479b8473794f19c9da (patch)
tree805ddc37482556fac351fa2a9e20d0e93219ef2b /src/rpc/net.cpp
parentAllow network activity to be temporarily suspended. (diff)
downloaddiscoin-e38993bb36801d492cad87479b8473794f19c9da.tar.xz
discoin-e38993bb36801d492cad87479b8473794f19c9da.zip
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.
Diffstat (limited to 'src/rpc/net.cpp')
-rw-r--r--src/rpc/net.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index b011029f5..7f5b10799 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -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)