0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-06 14:19:59 -05:00

refactor: Convert min ping time from double to int64_t

This commit is contained in:
Ben Woosley 2020-03-03 08:40:29 -05:00
parent b054c46977
commit e6fc63ec7e
No known key found for this signature in database
GPG key ID: 6EE5F3785F78B345
5 changed files with 7 additions and 7 deletions

View file

@ -556,7 +556,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 :) // 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_ping_usec = nPingUsecTime;
stats.dMinPing = (((double)nMinPingUsecTime) / 1e6); stats.m_min_ping_usec = nMinPingUsecTime;
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

@ -598,7 +598,7 @@ public:
bool m_legacyWhitelisted; bool m_legacyWhitelisted;
int64_t m_ping_usec; int64_t m_ping_usec;
double dPingWait; double dPingWait;
double dMinPing; int64_t m_min_ping_usec;
CAmount minFeeFilter; CAmount minFeeFilter;
// Our address, as reported by the peer // Our address, as reported by the peer
std::string addrLocal; std::string addrLocal;

View file

@ -32,7 +32,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->dMinPing < pRight->dMinPing; return pLeft->m_min_ping_usec < pRight->m_min_ping_usec;
case PeerTableModel::Sent: case PeerTableModel::Sent:
return pLeft->nSendBytes < pRight->nSendBytes; return pLeft->nSendBytes < pRight->nSendBytes;
case PeerTableModel::Received: case PeerTableModel::Received:
@ -161,7 +161,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.dMinPing); return GUIUtil::formatPingTime(rec->nodeStats.m_min_ping_usec);
case Sent: case Sent:
return GUIUtil::formatBytes(rec->nodeStats.nSendBytes); return GUIUtil::formatBytes(rec->nodeStats.nSendBytes);
case Received: case Received:

View file

@ -1111,7 +1111,7 @@ void RPCConsole::updateNodeDetail(const CNodeCombinedStats *stats)
ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected)); ui->peerConnTime->setText(GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nTimeConnected));
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_ping_usec)); 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.dPingWait));
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.dMinPing)); ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_usec));
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

@ -167,8 +167,8 @@ static UniValue getpeerinfo(const JSONRPCRequest& request)
obj.pushKV("timeoffset", stats.nTimeOffset); obj.pushKV("timeoffset", stats.nTimeOffset);
if (stats.m_ping_usec > 0) if (stats.m_ping_usec > 0)
obj.pushKV("pingtime", stats.m_ping_usec / 1e6); obj.pushKV("pingtime", stats.m_ping_usec / 1e6);
if (stats.dMinPing < static_cast<double>(std::numeric_limits<int64_t>::max())/1e6) if (stats.m_min_ping_usec < std::numeric_limits<int64_t>::max())
obj.pushKV("minping", stats.dMinPing); obj.pushKV("minping", stats.m_min_ping_usec / 1e6);
if (stats.dPingWait > 0.0) if (stats.dPingWait > 0.0)
obj.pushKV("pingwait", stats.dPingWait); obj.pushKV("pingwait", stats.dPingWait);
obj.pushKV("version", stats.nVersion); obj.pushKV("version", stats.nVersion);