diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2020-03-03 08:42:50 -0500 |
---|---|---|
committer | Ben Woosley <ben.woosley@gmail.com> | 2020-03-04 13:45:29 -0500 |
commit | 7a810b1d7a9d03818706dc94457dc3255f062796 (patch) | |
tree | 6879f95472c704bc48e85beaca23b91b330f1c46 /src | |
parent | e6fc63ec7ee637a4b533e4d7b22def05e74e1dff (diff) |
refactor: Convert ping wait time from double to int64_t
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 2 | ||||
-rw-r--r-- | src/net.h | 2 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 5 | ||||
-rw-r--r-- | src/qt/guiutil.h | 3 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 2 | ||||
-rw-r--r-- | src/rpc/net.cpp | 4 |
6 files changed, 5 insertions, 13 deletions
diff --git a/src/net.cpp b/src/net.cpp index 8177ca3e3b..d156450394 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -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 diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 88dc87a7fc..98dde1656a 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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)); diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 913d38c48a..e571262443 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -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); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 896675a493..b82ab9ffe8 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -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))); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index c1b350526d..e8ae458c57 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -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 |