Merge #8925: qt: Display minimum ping in debug window.

1724a40 Display minimum ping in debug window. (R E Broadley)
This commit is contained in:
Wladimir J. van der Laan 2016-10-18 14:48:55 +02:00
commit f628d9a29a
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
7 changed files with 34 additions and 10 deletions

View File

@ -659,7 +659,7 @@ void CNode::copyStats(CNodeStats &stats)
// Raw ping time is in microseconds, but show it to user as whole seconds (Bitcoin users should be well used to small numbers with many decimal places by now :) // Raw ping time is in microseconds, but show it to user as whole seconds (Bitcoin users should be well used to small numbers with many decimal places by now :)
stats.dPingTime = (((double)nPingUsecTime) / 1e6); stats.dPingTime = (((double)nPingUsecTime) / 1e6);
stats.dPingMin = (((double)nMinPingUsecTime) / 1e6); stats.dMinPing = (((double)nMinPingUsecTime) / 1e6);
stats.dPingWait = (((double)nPingUsecWait) / 1e6); stats.dPingWait = (((double)nPingUsecWait) / 1e6);
// Leave string empty if addrLocal invalid (not filled in yet) // Leave string empty if addrLocal invalid (not filled in yet)

View File

@ -503,7 +503,7 @@ public:
bool fWhitelisted; bool fWhitelisted;
double dPingTime; double dPingTime;
double dPingWait; double dPingWait;
double dPingMin; double dMinPing;
std::string addrLocal; std::string addrLocal;
CAddress addr; CAddress addr;
}; };

View File

@ -1353,13 +1353,36 @@
</widget> </widget>
</item> </item>
<item row="16" column="0"> <item row="16" column="0">
<widget class="QLabel" name="peerMinPingLabel">
<property name="text">
<string>Min Ping</string>
</property>
</widget>
</item>
<item row="16" column="2">
<widget class="QLabel" name="peerMinPing">
<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="17" column="0">
<widget class="QLabel" name="label_timeoffset"> <widget class="QLabel" name="label_timeoffset">
<property name="text"> <property name="text">
<string>Time Offset</string> <string>Time Offset</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="16" column="2"> <item row="17" column="2">
<widget class="QLabel" name="timeoffset"> <widget class="QLabel" name="timeoffset">
<property name="cursor"> <property name="cursor">
<cursorShape>IBeamCursor</cursorShape> <cursorShape>IBeamCursor</cursorShape>
@ -1375,7 +1398,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="17" column="1"> <item row="18" column="1">
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View File

@ -947,7 +947,7 @@ QString formatServicesStr(quint64 mask)
QString formatPingTime(double dPingTime) 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 == std::numeric_limits<int64_t>::max()/1e6 || dPingTime == 0) ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(dPingTime * 1000), 10));
} }
QString formatTimeOffset(int64_t nTimeOffset) QString formatTimeOffset(int64_t nTimeOffset)

View File

@ -31,7 +31,7 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
case PeerTableModel::Subversion: case PeerTableModel::Subversion:
return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0;
case PeerTableModel::Ping: case PeerTableModel::Ping:
return pLeft->dPingTime < pRight->dPingTime; return pLeft->dMinPing < pRight->dMinPing;
} }
return false; return false;
@ -113,7 +113,7 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
clientModel(parent), clientModel(parent),
timer(0) timer(0)
{ {
columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping Time"); columns << tr("NodeId") << tr("Node/Service") << tr("User Agent") << tr("Ping");
priv = new PeerTablePriv(); priv = new PeerTablePriv();
// default to unsorted // default to unsorted
priv->sortColumn = -1; priv->sortColumn = -1;
@ -166,7 +166,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
case Subversion: case Subversion:
return QString::fromStdString(rec->nodeStats.cleanSubVer); return QString::fromStdString(rec->nodeStats.cleanSubVer);
case Ping: case Ping:
return GUIUtil::formatPingTime(rec->nodeStats.dPingTime); return GUIUtil::formatPingTime(rec->nodeStats.dMinPing);
} }
} else if (role == Qt::TextAlignmentRole) { } else if (role == Qt::TextAlignmentRole) {
if (index.column() == Ping) if (index.column() == Ping)

View File

@ -895,6 +895,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
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->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait)); ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.dMinPing));
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset)); ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion))); ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion)));
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));

View File

@ -141,8 +141,8 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("timeoffset", stats.nTimeOffset)); obj.push_back(Pair("timeoffset", stats.nTimeOffset));
if (stats.dPingTime > 0.0) if (stats.dPingTime > 0.0)
obj.push_back(Pair("pingtime", stats.dPingTime)); obj.push_back(Pair("pingtime", stats.dPingTime));
if (stats.dPingMin < std::numeric_limits<int64_t>::max()/1e6) if (stats.dMinPing < std::numeric_limits<int64_t>::max()/1e6)
obj.push_back(Pair("minping", stats.dPingMin)); obj.push_back(Pair("minping", stats.dMinPing));
if (stats.dPingWait > 0.0) if (stats.dPingWait > 0.0)
obj.push_back(Pair("pingwait", stats.dPingWait)); obj.push_back(Pair("pingwait", stats.dPingWait));
obj.push_back(Pair("version", stats.nVersion)); obj.push_back(Pair("version", stats.nVersion));