Browse Source

Merge pull request #5476

73caf47 Display time offset in the debug window's Peers tab (Pavel Janík)
26a6bae Add time offset to getpeerinfo output (Pavel Janík)
0.13
Wladimir J. van der Laan 10 years ago
parent
commit
c986972ad7
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 4
      src/main.cpp
  2. 2
      src/net.cpp
  3. 2
      src/net.h
  4. 25
      src/qt/forms/rpcconsole.ui
  5. 5
      src/qt/guiutil.cpp
  6. 3
      src/qt/guiutil.h
  7. 1
      src/qt/rpcconsole.cpp
  8. 2
      src/rpcnet.cpp
  9. 4
      src/timedata.cpp

4
src/main.cpp

@ -3548,7 +3548,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);
} }

2
src/net.cpp

@ -522,6 +522,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);
@ -1933,6 +1934,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;

2
src/net.h

@ -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;

25
src/qt/forms/rpcconsole.ui

@ -1043,7 +1043,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="14" column="1"> <item row="14" column="0">
<widget class="QLabel" name="label_timeoffset">
<property name="text">
<string>Time Offset</string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="QLabel" name="timeoffset">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string>N/A</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="15" column="1">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

5
src/qt/guiutil.cpp

@ -843,4 +843,9 @@ QString formatPingTime(double dPingTime)
return dPingTime == 0 ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(dPingTime * 1000), 10)); return dPingTime == 0 ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(dPingTime * 1000), 10));
} }
QString formatTimeOffset(int64_t nTimeOffset)
{
return QString(QObject::tr("%1 s")).arg(QString::number((int)nTimeOffset, 10));
}
} // namespace GUIUtil } // namespace GUIUtil

3
src/qt/guiutil.h

@ -189,6 +189,9 @@ namespace GUIUtil
/* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/ /* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/
QString formatPingTime(double dPingTime); QString formatPingTime(double dPingTime);
/* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */
QString formatTimeOffset(int64_t nTimeOffset);
#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000 #if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
// workaround for Qt OSX Bug: // workaround for Qt OSX Bug:
// https://bugreports.qt-project.org/browse/QTBUG-15631 // https://bugreports.qt-project.org/browse/QTBUG-15631

1
src/qt/rpcconsole.cpp

@ -610,6 +610,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes)); ui->peerBytesRecv->setText(FormatBytes(stats->nodeStats.nRecvBytes));
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected)); ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetTime() - stats->nodeStats.nTimeConnected));
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime)); ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
ui->peerVersion->setText(QString("%1").arg(stats->nodeStats.nVersion)); ui->peerVersion->setText(QString("%1").arg(stats->nodeStats.nVersion));
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound")); ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound"));

2
src/rpcnet.cpp

@ -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));

4
src/timedata.cpp

@ -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…
Cancel
Save