From: fsb4000 Date: Wed, 12 Nov 2014 22:27:58 +0000 (+0600) Subject: getnettotals X-Git-Tag: nvc-v0.5.0~41^2~2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=a01b68db4ffd37a770b42fdd50080f5ce1b15732;hp=e5bad7e0ce0055de912222776edfae9059c6e3c7 getnettotals В биткоине, когда добавляли виджет монитор сетевого трафика, вместе с ним добавили RPC команду getnettotals Стоит добавить тоже. Возможно, она кому-нибудь пригодится. https://github.com/bitcoin/bitcoin/commit/ce14345a89dfa05992f8d2c7c9fe36315d4a67e6#diff-9a82240fe7dfe86564178691cc57f2f1R732 --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 80e6865..6cc82ef 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -248,6 +248,7 @@ static const CRPCCommand vRPCCommands[] = { "getsubsidy", &getsubsidy, true, false }, { "getmininginfo", &getmininginfo, true, false }, { "getnewaddress", &getnewaddress, true, false }, + { "getnettotals", &getnettotals, true, true }, { "getaccountaddress", &getaccountaddress, true, false }, { "setaccount", &setaccount, true, false }, { "getaccount", &getaccount, false, false }, diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index 0a0a788..44ab31d 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -151,6 +151,7 @@ extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fH extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value importaddress(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnettotals(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp); diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index ecc4331..f2fb213 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -137,3 +137,18 @@ Value sendalert(const Array& params, bool fHelp) result.push_back(Pair("nCancel", alert.nCancel)); return result; } + +Value getnettotals(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 0) + throw runtime_error( + "getnettotals\n" + "Returns information about network traffic, including bytes in, bytes out,\n" + "and current time."); + + Object obj; + obj.push_back(Pair("totalbytesrecv", static_cast< boost::uint64_t>(CNode::GetTotalBytesRecv()))); + obj.push_back(Pair("totalbytessent", static_cast(CNode::GetTotalBytesSent()))); + obj.push_back(Pair("timemillis", static_cast(GetTimeMillis()))); + return obj; +} \ No newline at end of file