Skip to content

Commit e1f7c7d

Browse files
committed
Merge pull request #4472
9f4da19 Use pong receive time rather than processing time (Pieter Wuille)
2 parents e81e2e8 + 9f4da19 commit e1f7c7d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,7 +3535,7 @@ void static ProcessGetData(CNode* pfrom)
35353535
}
35363536
}
35373537

3538-
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
3538+
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
35393539
{
35403540
RandAddSeedPerfmon();
35413541
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)
40454045

40464046
else if (strCommand == "pong")
40474047
{
4048-
int64_t pingUsecEnd = GetTimeMicros();
4048+
int64_t pingUsecEnd = nTimeReceived;
40494049
uint64_t nonce = 0;
40504050
size_t nAvail = vRecv.in_avail();
40514051
bool bPingFinished = false;
@@ -4296,7 +4296,7 @@ bool ProcessMessages(CNode* pfrom)
42964296
bool fRet = false;
42974297
try
42984298
{
4299-
fRet = ProcessMessage(pfrom, strCommand, vRecv);
4299+
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
43004300
boost::this_thread::interruption_point();
43014301
}
43024302
catch (std::ios_base::failure& e)

src/net.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,9 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
655655

656656
pch += handled;
657657
nBytes -= handled;
658+
659+
if (msg.complete())
660+
msg.nTime = GetTimeMicros();
658661
}
659662

660663
return true;

src/net.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,14 @@ class CNetMessage {
173173
CDataStream vRecv; // received message data
174174
unsigned int nDataPos;
175175

176+
int64_t nTime; // time (in microseconds) of message receipt.
177+
176178
CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) {
177179
hdrbuf.resize(24);
178180
in_data = false;
179181
nHdrPos = 0;
180182
nDataPos = 0;
183+
nTime = 0;
181184
}
182185

183186
bool complete() const

0 commit comments

Comments
 (0)