Skip to content

Commit fa97621

Browse files
author
MarcoFalke
committed
qt: Use steady clock to throttle GUI notifications
1 parent fa1d804 commit fa97621

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/qt/clientmodel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <QThread>
2828
#include <QTimer>
2929

30-
static int64_t nLastHeaderTipUpdateNotification = 0;
31-
static int64_t nLastBlockTipUpdateNotification = 0;
30+
static SteadyClock::time_point g_last_header_tip_update_notification{};
31+
static SteadyClock::time_point g_last_block_tip_update_notification{};
3232

3333
ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QObject *parent) :
3434
QObject(parent),
@@ -221,9 +221,9 @@ void ClientModel::TipChanged(SynchronizationState sync_state, interfaces::BlockT
221221

222222
// Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex.
223223
const bool throttle = (sync_state != SynchronizationState::POST_INIT && synctype == SyncType::BLOCK_SYNC) || sync_state == SynchronizationState::INIT_REINDEX;
224-
const int64_t now = throttle ? GetTimeMillis() : 0;
225-
int64_t& nLastUpdateNotification = synctype != SyncType::BLOCK_SYNC ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
226-
if (throttle && now < nLastUpdateNotification + count_milliseconds(MODEL_UPDATE_DELAY)) {
224+
const auto now{throttle ? SteadyClock::now() : SteadyClock::time_point{}};
225+
auto& nLastUpdateNotification = synctype != SyncType::BLOCK_SYNC ? g_last_header_tip_update_notification : g_last_block_tip_update_notification;
226+
if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
227227
return;
228228
}
229229

0 commit comments

Comments
 (0)