mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
Add time offset to getpeerinfo output
This commit is contained in:
parent
13c077c7cf
commit
26a6bae753
@ -3450,7 +3450,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
pfrom->nStartingHeight, addrMe.ToString(), pfrom->id,
|
pfrom->nStartingHeight, addrMe.ToString(), pfrom->id,
|
||||||
remoteAddr);
|
remoteAddr);
|
||||||
|
|
||||||
AddTimeData(pfrom->addr, nTime);
|
int64_t nTimeOffset = nTime - GetTime();
|
||||||
|
pfrom->nTimeOffset = nTimeOffset;
|
||||||
|
AddTimeData(pfrom->addr, nTimeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,6 +523,7 @@ void CNode::copyStats(CNodeStats &stats)
|
|||||||
X(nLastSend);
|
X(nLastSend);
|
||||||
X(nLastRecv);
|
X(nLastRecv);
|
||||||
X(nTimeConnected);
|
X(nTimeConnected);
|
||||||
|
X(nTimeOffset);
|
||||||
X(addrName);
|
X(addrName);
|
||||||
X(nVersion);
|
X(nVersion);
|
||||||
X(cleanSubVer);
|
X(cleanSubVer);
|
||||||
@ -1934,6 +1935,7 @@ CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fIn
|
|||||||
nSendBytes = 0;
|
nSendBytes = 0;
|
||||||
nRecvBytes = 0;
|
nRecvBytes = 0;
|
||||||
nTimeConnected = GetTime();
|
nTimeConnected = GetTime();
|
||||||
|
nTimeOffset = 0;
|
||||||
addr = addrIn;
|
addr = addrIn;
|
||||||
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
|
||||||
nVersion = 0;
|
nVersion = 0;
|
||||||
|
@ -154,6 +154,7 @@ public:
|
|||||||
int64_t nLastSend;
|
int64_t nLastSend;
|
||||||
int64_t nLastRecv;
|
int64_t nLastRecv;
|
||||||
int64_t nTimeConnected;
|
int64_t nTimeConnected;
|
||||||
|
int64_t nTimeOffset;
|
||||||
std::string addrName;
|
std::string addrName;
|
||||||
int nVersion;
|
int nVersion;
|
||||||
std::string cleanSubVer;
|
std::string cleanSubVer;
|
||||||
@ -235,6 +236,7 @@ public:
|
|||||||
int64_t nLastSend;
|
int64_t nLastSend;
|
||||||
int64_t nLastRecv;
|
int64_t nLastRecv;
|
||||||
int64_t nTimeConnected;
|
int64_t nTimeConnected;
|
||||||
|
int64_t nTimeOffset;
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
std::string addrName;
|
std::string addrName;
|
||||||
CService addrLocal;
|
CService addrLocal;
|
||||||
|
@ -91,6 +91,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
|||||||
" \"bytessent\": n, (numeric) The total bytes sent\n"
|
" \"bytessent\": n, (numeric) The total bytes sent\n"
|
||||||
" \"bytesrecv\": n, (numeric) The total bytes received\n"
|
" \"bytesrecv\": n, (numeric) The total bytes received\n"
|
||||||
" \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n"
|
" \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n"
|
||||||
|
" \"timeoffset\": ttt, (numeric) The time offset in seconds\n"
|
||||||
" \"pingtime\": n, (numeric) ping time\n"
|
" \"pingtime\": n, (numeric) ping time\n"
|
||||||
" \"pingwait\": n, (numeric) ping wait\n"
|
" \"pingwait\": n, (numeric) ping wait\n"
|
||||||
" \"version\": v, (numeric) The peer version, such as 7001\n"
|
" \"version\": v, (numeric) The peer version, such as 7001\n"
|
||||||
@ -131,6 +132,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
|
|||||||
obj.push_back(Pair("bytessent", stats.nSendBytes));
|
obj.push_back(Pair("bytessent", stats.nSendBytes));
|
||||||
obj.push_back(Pair("bytesrecv", stats.nRecvBytes));
|
obj.push_back(Pair("bytesrecv", stats.nRecvBytes));
|
||||||
obj.push_back(Pair("conntime", stats.nTimeConnected));
|
obj.push_back(Pair("conntime", stats.nTimeConnected));
|
||||||
|
obj.push_back(Pair("timeoffset", stats.nTimeOffset));
|
||||||
obj.push_back(Pair("pingtime", stats.dPingTime));
|
obj.push_back(Pair("pingtime", stats.dPingTime));
|
||||||
if (stats.dPingWait > 0.0)
|
if (stats.dPingWait > 0.0)
|
||||||
obj.push_back(Pair("pingwait", stats.dPingWait));
|
obj.push_back(Pair("pingwait", stats.dPingWait));
|
||||||
|
@ -40,10 +40,8 @@ static int64_t abs64(int64_t n)
|
|||||||
return (n >= 0 ? n : -n);
|
return (n >= 0 ? n : -n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTimeData(const CNetAddr& ip, int64_t nTime)
|
void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
||||||
{
|
{
|
||||||
int64_t nOffsetSample = nTime - GetTime();
|
|
||||||
|
|
||||||
LOCK(cs_nTimeOffset);
|
LOCK(cs_nTimeOffset);
|
||||||
// Ignore duplicates
|
// Ignore duplicates
|
||||||
static set<CNetAddr> setKnown;
|
static set<CNetAddr> setKnown;
|
||||||
|
Loading…
Reference in New Issue
Block a user