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)
{ {
// Send block from disk // Send block from disk
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash); map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash);
pfrom->nBlocksRequested++;
if (mi != mapBlockIndex.end()) if (mi != mapBlockIndex.end())
{ {
CBlock block; CBlock block;

1
src/net.cpp

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

3
src/net.h

@ -104,6 +104,7 @@ public:
int nMisbehavior; int nMisbehavior;
uint64 nSendBytes; uint64 nSendBytes;
uint64 nRecvBytes; uint64 nRecvBytes;
uint64 nBlocksRequested;
bool fSyncNode; bool fSyncNode;
}; };
@ -173,6 +174,7 @@ public:
int64 nLastRecv; int64 nLastRecv;
int64 nLastSendEmpty; int64 nLastSendEmpty;
int64 nTimeConnected; int64 nTimeConnected;
uint64 nBlocksRequested;
CAddress addr; CAddress addr;
std::string addrName; std::string addrName;
CService addrLocal; CService addrLocal;
@ -231,6 +233,7 @@ public:
nRecvBytes = 0; nRecvBytes = 0;
nLastSendEmpty = GetTime(); nLastSendEmpty = GetTime();
nTimeConnected = GetTime(); nTimeConnected = GetTime();
nBlocksRequested = 0;
addr = addrIn; addr = addrIn;
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
nVersion = 0; nVersion = 0;

1
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("lastrecv", (boost::int64_t)stats.nLastRecv));
obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes)); obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes));
obj.push_back(Pair("bytesrecv", (boost::int64_t)stats.nRecvBytes)); 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("conntime", (boost::int64_t)stats.nTimeConnected));
obj.push_back(Pair("version", stats.nVersion)); obj.push_back(Pair("version", stats.nVersion));
obj.push_back(Pair("subver", stats.strSubVer)); obj.push_back(Pair("subver", stats.strSubVer));

Loading…
Cancel
Save