From: CryptoManiac Date: Mon, 28 Jul 2014 19:06:46 +0000 (+0400) Subject: Add bytessent, bytesrecv and syncnode to getpeerinfo X-Git-Tag: v0.4.4.6-nvc-update7~5^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=8de38355024dfd223507471a54a66793e1245f63;hp=28f9882707d389250e307ebf58dcf981340f1381 Add bytessent, bytesrecv and syncnode to getpeerinfo --- diff --git a/src/net.cpp b/src/net.cpp index cd826d6..6387e10 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -636,6 +636,9 @@ void CNode::copyStats(CNodeStats &stats) X(nReleaseTime); X(nStartingHeight); X(nMisbehavior); + X(nSendBytes); + X(nRecvBytes); + stats.fSyncNode = (this == pnodeSync); } #undef X @@ -908,6 +911,7 @@ void ThreadSocketHandler2(void* parg) vRecv.resize(nPos + nBytes); memcpy(&vRecv[nPos], pchBuf, nBytes); pnode->nLastRecv = GetTime(); + pnode->nRecvBytes += nBytes; } else if (nBytes == 0) { @@ -949,6 +953,7 @@ void ThreadSocketHandler2(void* parg) { vSend.erase(vSend.begin(), vSend.begin() + nBytes); pnode->nLastSend = GetTime(); + pnode->nSendBytes += nBytes; } else if (nBytes < 0) { diff --git a/src/net.h b/src/net.h index c1d478a..cf80be2 100644 --- a/src/net.h +++ b/src/net.h @@ -145,6 +145,9 @@ public: int64 nReleaseTime; int nStartingHeight; int nMisbehavior; + uint64 nSendBytes; + uint64 nRecvBytes; + bool fSyncNode; }; @@ -160,6 +163,8 @@ public: SOCKET hSocket; CDataStream vSend; CDataStream vRecv; + uint64 nSendBytes; + uint64 nRecvBytes; CCriticalSection cs_vSend; CCriticalSection cs_vRecv; int64 nLastSend; @@ -218,6 +223,8 @@ public: hSocket = hSocketIn; nLastSend = 0; nLastRecv = 0; + nSendBytes = 0; + nRecvBytes = 0; nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); nHeaderStart = -1; diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 04ea310..ecc4331 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -55,6 +55,8 @@ Value getpeerinfo(const Array& params, bool fHelp) obj.push_back(Pair("services", strprintf("%08"PRI64x, 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)); @@ -62,7 +64,8 @@ Value getpeerinfo(const Array& params, bool fHelp) 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); }