mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
merge bitcoin#18260: Fix implicit value conversion in formatPingTime
This commit is contained in:
parent
31cdcb64b8
commit
d949c90bc0
@ -628,9 +628,9 @@ void CNode::copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap)
|
||||
}
|
||||
|
||||
// Raw ping time is in microseconds, but show it to user as whole seconds (Dash users should be well used to small numbers with many decimal places by now :)
|
||||
stats.dPingTime = (((double)nPingUsecTime) / 1e6);
|
||||
stats.dMinPing = (((double)nMinPingUsecTime) / 1e6);
|
||||
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
|
||||
stats.m_ping_usec = nPingUsecTime;
|
||||
stats.m_min_ping_usec = nMinPingUsecTime;
|
||||
stats.m_ping_wait_usec = nPingUsecWait;
|
||||
|
||||
// Leave string empty if addrLocal invalid (not filled in yet)
|
||||
CService addrLocalUnlocked = GetAddrLocal();
|
||||
|
@ -763,9 +763,9 @@ public:
|
||||
mapMsgCmdSize mapRecvBytesPerMsgCmd;
|
||||
NetPermissionFlags m_permissionFlags;
|
||||
bool m_legacyWhitelisted;
|
||||
double dPingTime;
|
||||
double dPingWait;
|
||||
double dMinPing;
|
||||
int64_t m_ping_usec;
|
||||
int64_t m_ping_wait_usec;
|
||||
int64_t m_min_ping_usec;
|
||||
// Our address, as reported by the peer
|
||||
std::string addrLocal;
|
||||
// Address of this peer
|
||||
|
@ -1757,9 +1757,9 @@ QString formatServicesStr(quint64 mask)
|
||||
return QObject::tr("None");
|
||||
}
|
||||
|
||||
QString formatPingTime(double dPingTime)
|
||||
QString formatPingTime(int64_t ping_usec)
|
||||
{
|
||||
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));
|
||||
return (ping_usec == std::numeric_limits<int64_t>::max() || ping_usec == 0) ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(ping_usec / 1000), 10));
|
||||
}
|
||||
|
||||
QString formatTimeOffset(int64_t nTimeOffset)
|
||||
|
@ -407,8 +407,8 @@ namespace GUIUtil
|
||||
/* Format CNodeStats.nServices bitmask into a user-readable string */
|
||||
QString formatServicesStr(quint64 mask);
|
||||
|
||||
/* Format a CNodeCombinedStats.dPingTime into a user-readable string or display N/A, if 0*/
|
||||
QString formatPingTime(double dPingTime);
|
||||
/* Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0*/
|
||||
QString formatPingTime(int64_t ping_usec);
|
||||
|
||||
/* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */
|
||||
QString formatTimeOffset(int64_t nTimeOffset);
|
||||
|
@ -35,7 +35,7 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
|
||||
case PeerTableModel::Subversion:
|
||||
return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0;
|
||||
case PeerTableModel::Ping:
|
||||
return pLeft->dMinPing < pRight->dMinPing;
|
||||
return pLeft->m_min_ping_usec < pRight->m_min_ping_usec;
|
||||
case PeerTableModel::Sent:
|
||||
return pLeft->nSendBytes < pRight->nSendBytes;
|
||||
case PeerTableModel::Received:
|
||||
@ -170,7 +170,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
|
||||
case Subversion:
|
||||
return QString::fromStdString(rec->nodeStats.cleanSubVer);
|
||||
case Ping:
|
||||
return GUIUtil::formatPingTime(rec->nodeStats.dMinPing);
|
||||
return GUIUtil::formatPingTime(rec->nodeStats.m_min_ping_usec);
|
||||
case Sent:
|
||||
return GUIUtil::formatBytes(rec->nodeStats.nSendBytes);
|
||||
case Received:
|
||||
|
@ -1253,9 +1253,9 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
|
||||
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
|
||||
ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
|
||||
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
|
||||
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingTime));
|
||||
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
|
||||
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.dMinPing));
|
||||
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_ping_usec));
|
||||
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.m_ping_wait_usec));
|
||||
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_usec));
|
||||
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
|
||||
ui->peerVersion->setText(QString("%1").arg(QString::number(stats->nodeStats.nVersion)));
|
||||
ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer));
|
||||
|
@ -178,12 +178,15 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||
obj.pushKV("bytesrecv", stats.nRecvBytes);
|
||||
obj.pushKV("conntime", stats.nTimeConnected);
|
||||
obj.pushKV("timeoffset", stats.nTimeOffset);
|
||||
if (stats.dPingTime > 0.0)
|
||||
obj.pushKV("pingtime", stats.dPingTime);
|
||||
if (stats.dMinPing < static_cast<double>(std::numeric_limits<int64_t>::max())/1e6)
|
||||
obj.pushKV("minping", stats.dMinPing);
|
||||
if (stats.dPingWait > 0.0)
|
||||
obj.pushKV("pingwait", stats.dPingWait);
|
||||
if (stats.m_ping_usec > 0) {
|
||||
obj.pushKV("pingtime", ((double)stats.m_ping_usec) / 1e6);
|
||||
}
|
||||
if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max()) {
|
||||
obj.pushKV("minping", ((double)stats.m_min_ping_usec) / 1e6);
|
||||
}
|
||||
if (stats.m_ping_wait_usec > 0) {
|
||||
obj.pushKV("pingwait", ((double)stats.m_ping_wait_usec) / 1e6);
|
||||
}
|
||||
obj.pushKV("version", stats.nVersion);
|
||||
// Use the sanitized form of subver here, to avoid tricksy remote peers from
|
||||
// corrupting or modifying the JSON output by putting special characters in
|
||||
|
Loading…
Reference in New Issue
Block a user