mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
refactor: Convert ping wait time from double to int64_t
This commit is contained in:
parent
e6fc63ec7e
commit
7a810b1d7a
6 changed files with 5 additions and 13 deletions
|
@ -557,7 +557,7 @@ 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 (Bitcoin users should be well used to small numbers with many decimal places by now :)
|
||||
stats.m_ping_usec = nPingUsecTime;
|
||||
stats.m_min_ping_usec = nMinPingUsecTime;
|
||||
stats.dPingWait = (((double)nPingUsecWait) / 1e6);
|
||||
stats.m_ping_wait_usec = nPingUsecWait;
|
||||
|
||||
// Leave string empty if addrLocal invalid (not filled in yet)
|
||||
CService addrLocalUnlocked = GetAddrLocal();
|
||||
|
|
|
@ -597,7 +597,7 @@ public:
|
|||
NetPermissionFlags m_permissionFlags;
|
||||
bool m_legacyWhitelisted;
|
||||
int64_t m_ping_usec;
|
||||
double dPingWait;
|
||||
int64_t m_ping_wait_usec;
|
||||
int64_t m_min_ping_usec;
|
||||
CAmount minFeeFilter;
|
||||
// Our address, as reported by the peer
|
||||
|
|
|
@ -773,11 +773,6 @@ QString formatServicesStr(quint64 mask)
|
|||
return QObject::tr("None");
|
||||
}
|
||||
|
||||
QString formatPingTime(double dPingTime)
|
||||
{
|
||||
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 formatPingTime(int64_t ping_usec)
|
||||
{
|
||||
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));
|
||||
|
|
|
@ -202,9 +202,6 @@ 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);
|
||||
|
||||
|
|
|
@ -1110,7 +1110,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
|
|||
ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
|
||||
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
|
||||
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_ping_usec));
|
||||
ui->peerPingWait->setText(GUIUtil::formatPingTime(stats->nodeStats.dPingWait));
|
||||
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)));
|
||||
|
|
|
@ -169,8 +169,8 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
|
|||
obj.pushKV("pingtime", stats.m_ping_usec / 1e6);
|
||||
if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max())
|
||||
obj.pushKV("minping", stats.m_min_ping_usec / 1e6);
|
||||
if (stats.dPingWait > 0.0)
|
||||
obj.pushKV("pingwait", stats.dPingWait);
|
||||
if (stats.m_ping_wait_usec > 0)
|
||||
obj.pushKV("pingwait", 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 a new issue