aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2014-07-06 16:06:46 +0200
committerRoss Nicoll <[email protected]>2015-06-27 13:45:18 +0000
commitd0952adabdd231935ba160e498f554a912277e18 (patch)
tree7eb268f0cdca551e1fe16d05837667b551cbd6c0
parentadd missing BOOST_FOREACH indentation in ThreadSocketHandler() (diff)
downloaddiscoin-d0952adabdd231935ba160e498f554a912277e18.tar.xz
discoin-d0952adabdd231935ba160e498f554a912277e18.zip
Use pong receive time rather than processing time
-rw-r--r--src/main.cpp6
-rw-r--r--src/net.cpp3
-rw-r--r--src/net.h3
3 files changed, 9 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 31d354c47..be1b33186 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3737,7 +3737,7 @@ void static ProcessGetData(CNode* pfrom)
}
}
-bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
+bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
{
RandAddSeedPerfmon();
LogPrint("net", "received: %s (%" PRIszu" bytes)\n", strCommand, vRecv.size());
@@ -4257,7 +4257,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else if (strCommand == "pong")
{
- int64_t pingUsecEnd = GetTimeMicros();
+ int64_t pingUsecEnd = nTimeReceived;
uint64_t nonce = 0;
size_t nAvail = vRecv.in_avail();
bool bPingFinished = false;
@@ -4513,7 +4513,7 @@ bool ProcessMessages(CNode* pfrom)
bool fRet = false;
try
{
- fRet = ProcessMessage(pfrom, strCommand, vRecv);
+ fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
boost::this_thread::interruption_point();
}
catch (std::ios_base::failure& e)
diff --git a/src/net.cpp b/src/net.cpp
index c02bf271f..26543c329 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -639,6 +639,9 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
pch += handled;
nBytes -= handled;
+
+ if (msg.complete())
+ msg.nTime = GetTimeMicros();
}
return true;
diff --git a/src/net.h b/src/net.h
index 6fece5af4..6f4e0797e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -168,11 +168,14 @@ public:
CDataStream vRecv; // received message data
unsigned int nDataPos;
+ int64_t nTime; // time (in microseconds) of message receipt.
+
CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) {
hdrbuf.resize(24);
in_data = false;
nHdrPos = 0;
nDataPos = 0;
+ nTime = 0;
}
bool complete() const