mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
qt: add RPCConsole::TimeDurationField helper, call systime only once
This commit is contained in:
parent
b54a10e777
commit
4dc2fd6c37
2 changed files with 9 additions and 3 deletions
|
@ -1120,11 +1120,12 @@ void RPCConsole::updateDetailWidget()
|
|||
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings == "" ? "From" : "/From");
|
||||
if (bip152_hb_settings == "") bip152_hb_settings = "No";
|
||||
ui->peerHighBandwidth->setText(bip152_hb_settings);
|
||||
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastSend) : tr("never"));
|
||||
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastRecv) : tr("never"));
|
||||
const int64_t time_now{GetSystemTimeInSeconds()};
|
||||
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
|
||||
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.nLastSend));
|
||||
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.nLastRecv));
|
||||
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.m_ping_usec));
|
||||
ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_usec));
|
||||
ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset));
|
||||
|
|
|
@ -168,6 +168,11 @@ private:
|
|||
/** Update UI with latest network info from model. */
|
||||
void updateNetworkState();
|
||||
|
||||
/** Helper for the output of a time duration field. Inputs are UNIX epoch times. */
|
||||
QString TimeDurationField(uint64_t time_now, uint64_t time_at_event) const {
|
||||
return time_at_event ? GUIUtil::formatDurationStr(time_now - time_at_event) : tr("Never");
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateAlerts(const QString& warnings);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue