Browse Source

Track blocks requested by peers

0.8
Peter Todd 11 years ago committed by Warren Togami
parent
commit
a42627b5ec
  1. 1
      src/main.cpp
  2. 1
      src/net.cpp
  3. 3
      src/net.h
  4. 1
      src/rpcnet.cpp

1
src/main.cpp

@ -3077,6 +3077,7 @@ void static ProcessGetData(CNode* pfrom) @@ -3077,6 +3077,7 @@ void static ProcessGetData(CNode* pfrom)
{
// Send block from disk
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash);
pfrom->nBlocksRequested++;
if (mi != mapBlockIndex.end())
{
CBlock block;

1
src/net.cpp

@ -618,6 +618,7 @@ void CNode::copyStats(CNodeStats &stats) @@ -618,6 +618,7 @@ void CNode::copyStats(CNodeStats &stats)
X(nMisbehavior);
X(nSendBytes);
X(nRecvBytes);
X(nBlocksRequested);
stats.fSyncNode = (this == pnodeSync);
}
#undef X

3
src/net.h

@ -104,6 +104,7 @@ public: @@ -104,6 +104,7 @@ public:
int nMisbehavior;
uint64 nSendBytes;
uint64 nRecvBytes;
uint64 nBlocksRequested;
bool fSyncNode;
};
@ -173,6 +174,7 @@ public: @@ -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: @@ -231,6 +233,7 @@ public:
nRecvBytes = 0;
nLastSendEmpty = GetTime();
nTimeConnected = GetTime();
nBlocksRequested = 0;
addr = addrIn;
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
nVersion = 0;

1
src/rpcnet.cpp

@ -53,6 +53,7 @@ Value getpeerinfo(const Array& params, bool fHelp) @@ -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));

Loading…
Cancel
Save