// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "net.h"
#include "bitcoinrpc.h"
#include "alert.h"
#include "wallet.h"
#include "db.h"
#include "walletdb.h"
+#include "net.h"
using namespace json_spirit;
using namespace std;
Object obj;
obj.push_back(Pair("addr", stats.addrName));
- obj.push_back(Pair("services", strprintf("%08"PRI64x, stats.nServices)));
+ obj.push_back(Pair("services", strprintf("%08" PRIx64, stats.nServices)));
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));
+ obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes));
+ obj.push_back(Pair("bytesrecv", (boost::int64_t)stats.nRecvBytes));
obj.push_back(Pair("conntime", (boost::int64_t)stats.nTimeConnected));
obj.push_back(Pair("version", stats.nVersion));
obj.push_back(Pair("subver", stats.strSubVer));
obj.push_back(Pair("releasetime", (boost::int64_t)stats.nReleaseTime));
obj.push_back(Pair("startingheight", stats.nStartingHeight));
obj.push_back(Pair("banscore", stats.nMisbehavior));
-
+ if (stats.fSyncNode)
+ obj.push_back(Pair("syncnode", true));
ret.push_back(obj);
}
return ret;
}
+Value addnode(const Array& params, bool fHelp)
+{
+ string strCommand;
+ if (params.size() == 2)
+ strCommand = params[1].get_str();
+ if (fHelp || params.size() != 2 ||
+ (strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
+ throw runtime_error(
+ "addnode <node> <add|remove|onetry>\n"
+ "Attempts add or remove <node> from the addnode list or try a connection to <node> once.");
+
+ string strNode = params[0].get_str();
+
+ if (strCommand == "onetry")
+ {
+ CAddress addr;
+ ConnectNode(addr, strNode.c_str());
+ return Value::null;
+ }
+
+ LOCK(cs_vAddedNodes);
+ vector<string>::iterator it = vAddedNodes.begin();
+ for(; it != vAddedNodes.end(); it++)
+ if (strNode == *it)
+ break;
+
+ if (strCommand == "add")
+ {
+ if (it != vAddedNodes.end())
+ throw JSONRPCError(-23, "Error: Node already added");
+ vAddedNodes.push_back(strNode);
+ }
+ else if(strCommand == "remove")
+ {
+ if (it == vAddedNodes.end())
+ throw JSONRPCError(-24, "Error: Node has not been added.");
+ vAddedNodes.erase(it);
+ }
+
+ return Value::null;
+}
+
+
extern CCriticalSection cs_mapAlerts;
extern map<uint256, CAlert> mapAlerts;
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<boost::uint64_t>(CNode::GetTotalBytesSent())));
+ obj.push_back(Pair("timemillis", static_cast<boost::int64_t>(GetTimeMillis())));
+ return obj;
+}
\ No newline at end of file