From a42627b5ecd358e8a5fade01fe5f4a040d40b6ac Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Wed, 21 Aug 2013 06:20:51 -0400 Subject: [PATCH] Track blocks requested by peers --- src/main.cpp | 1 + src/net.cpp | 1 + src/net.h | 3 +++ src/rpcnet.cpp | 1 + 4 files changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 4a2aeeaa0..a90af4898 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3077,6 +3077,7 @@ void static ProcessGetData(CNode* pfrom) { // Send block from disk map::iterator mi = mapBlockIndex.find(inv.hash); + pfrom->nBlocksRequested++; if (mi != mapBlockIndex.end()) { CBlock block; diff --git a/src/net.cpp b/src/net.cpp index 4dc7a4727..7ece6c919 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -618,6 +618,7 @@ void CNode::copyStats(CNodeStats &stats) X(nMisbehavior); X(nSendBytes); X(nRecvBytes); + X(nBlocksRequested); stats.fSyncNode = (this == pnodeSync); } #undef X diff --git a/src/net.h b/src/net.h index 6f315f74f..b553ef93d 100644 --- a/src/net.h +++ b/src/net.h @@ -104,6 +104,7 @@ public: int nMisbehavior; uint64 nSendBytes; uint64 nRecvBytes; + uint64 nBlocksRequested; bool fSyncNode; }; @@ -173,6 +174,7 @@ public: int64 nLastRecv; int64 nLastSendEmpty; int64 nTimeConnected; + uint64 nBlocksRequested; CAddress addr; std::string addrName; CService addrLocal; @@ -231,6 +233,7 @@ public: nRecvBytes = 0; nLastSendEmpty = GetTime(); nTimeConnected = GetTime(); + nBlocksRequested = 0; addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 644c2675a..840ed4866 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -53,6 +53,7 @@ Value getpeerinfo(const Array& params, bool fHelp) 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("blocksrequested", (boost::int64_t)stats.nBlocksRequested)); obj.push_back(Pair("conntime", (boost::int64_t)stats.nTimeConnected)); obj.push_back(Pair("version", stats.nVersion)); obj.push_back(Pair("subver", stats.strSubVer));