aboutsummaryrefslogtreecommitdiff
path: root/src/rpcnet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-05-05 13:22:28 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-06 09:34:54 +0200
commitd387b8ec15e553db9b9c370314ee359e981fb374 (patch)
tree9d1b3a161e60aff59f00ee0e9ad1fcc75ccd5056 /src/rpcnet.cpp
parentd4ffe4e425b5a3f6fe4ff0ce7297608dfe6c7417 (diff)
rpc: add `getblockchaininfo` and `getnetworkinfo`
Adds two new info query commands that take over information from hodge-podge `getinfo`. Also some new information is added: - `getblockchaininfo` - `chain`: (string) current chain (main, testnet3, regtest) - `verificationprogress: (numeric) estimated verification progress - `chainwork` - `getnetworkinfo` - `localaddresses`: (array) local addresses, from mapLocalHost (fixes #1734)
Diffstat (limited to 'src/rpcnet.cpp')
-rw-r--r--src/rpcnet.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 1b56d9ae7d..573d6cd3f6 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -333,3 +333,54 @@ Value getnettotals(const Array& params, bool fHelp)
obj.push_back(Pair("timemillis", static_cast<boost::int64_t>(GetTimeMillis())));
return obj;
}
+
+Value getnetworkinfo(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() != 0)
+ throw runtime_error(
+ "getnetworkinfo\n"
+ "Returns an object containing various state info regarding P2P networking.\n"
+ "\nResult:\n"
+ "{\n"
+ " \"version\": xxxxx, (numeric) the server version\n"
+ " \"protocolversion\": xxxxx, (numeric) the protocol version\n"
+ " \"timeoffset\": xxxxx, (numeric) the time offset\n"
+ " \"connections\": xxxxx, (numeric) the number of connections\n"
+ " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
+ " \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in btc/kb\n"
+ " \"localaddresses\": [, (array) list of local addresses\n"
+ " \"address\": \"xxxx\", (string) network address\n"
+ " \"port\": xxx, (numeric) network port\n"
+ " \"score\": xxx (numeric) relative score\n"
+ " ]\n"
+ "}\n"
+ "\nExamples:\n"
+ + HelpExampleCli("getnetworkinfo", "")
+ + HelpExampleRpc("getnetworkinfo", "")
+ );
+
+ proxyType proxy;
+ GetProxy(NET_IPV4, proxy);
+
+ Object obj;
+ obj.push_back(Pair("version", (int)CLIENT_VERSION));
+ obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
+ obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));
+ obj.push_back(Pair("connections", (int)vNodes.size()));
+ obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
+ obj.push_back(Pair("relayfee", ValueFromAmount(CTransaction::nMinRelayTxFee)));
+ Array localAddresses;
+ {
+ LOCK(cs_mapLocalHost);
+ BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost)
+ {
+ Object rec;
+ rec.push_back(Pair("address", item.first.ToString()));
+ rec.push_back(Pair("port", item.second.nPort));
+ rec.push_back(Pair("score", item.second.nScore));
+ localAddresses.push_back(rec);
+ }
+ }
+ obj.push_back(Pair("localaddresses", localAddresses));
+ return obj;
+}