aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-07-07 06:28:12 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-07-07 06:28:43 +0200
commite1f7c7d173a7522673f4638a6125ac43e78d1258 (patch)
tree8c6e44066ac11a3b8dbb32da10a040905369f0e0
parente81e2e8f7cdee307227f150a6a2408c01fcafbf2 (diff)
parent9f4da19babf6989a639be29c70c1d2470c5829a6 (diff)
downloadbitcoin-e1f7c7d173a7522673f4638a6125ac43e78d1258.tar.xz
Merge pull request #4472
9f4da19 Use pong receive time rather than processing time (Pieter Wuille)
-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 b2773953d1..e08b794184 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3535,7 +3535,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 (%u bytes) peer=%d\n", strCommand, vRecv.size(), pfrom->id);
@@ -4045,7 +4045,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;
@@ -4296,7 +4296,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 c7bdb83aad..6a660dc9bd 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -655,6 +655,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 3b169f442f..c2a0416455 100644
--- a/src/net.h
+++ b/src/net.h
@@ -173,11 +173,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