aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/misc.cpp4
-rw-r--r--src/rpc/net.cpp19
2 files changed, 22 insertions, 1 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 5afcf6353c..4bfcc9387c 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -89,8 +89,10 @@ UniValue getinfo(const UniValue& params, bool fHelp)
#endif
obj.push_back(Pair("blocks", (int)chainActive.Height()));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
- if(g_connman)
+ if (g_connman) {
+ obj.push_back(Pair("networkactive", g_connman->GetNetworkActive()));
obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL)));
+ }
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index b011029f51..7f5b107997 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)