aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-04-03 09:58:49 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-04-04 12:34:05 +0200
commitfa976218044f3ff244abbd797b183a1408375c74 (patch)
tree1f8b165dd2e5ac6e0e7ee88dadcb8e2d6d41ac69 /src/qt/clientmodel.cpp
parentfa1d8044abc2cd0f149a2d526b3b03441443cdb0 (diff)
qt: Use steady clock to throttle GUI notifications
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 8411ec4696..d13a8bad5d 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -27,8 +27,8 @@
#include <QThread>
#include <QTimer>
-static int64_t nLastHeaderTipUpdateNotification = 0;
-static int64_t nLastBlockTipUpdateNotification = 0;
+static SteadyClock::time_point g_last_header_tip_update_notification{};
+static SteadyClock::time_point g_last_block_tip_update_notification{};
ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QObject *parent) :
QObject(parent),
@@ -221,9 +221,9 @@ void ClientModel::TipChanged(SynchronizationState sync_state, interfaces::BlockT
// Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex.
const bool throttle = (sync_state != SynchronizationState::POST_INIT && synctype == SyncType::BLOCK_SYNC) || sync_state == SynchronizationState::INIT_REINDEX;
- const int64_t now = throttle ? GetTimeMillis() : 0;
- int64_t& nLastUpdateNotification = synctype != SyncType::BLOCK_SYNC ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
- if (throttle && now < nLastUpdateNotification + count_milliseconds(MODEL_UPDATE_DELAY)) {
+ const auto now{throttle ? SteadyClock::now() : SteadyClock::time_point{}};
+ auto& nLastUpdateNotification = synctype != SyncType::BLOCK_SYNC ? g_last_header_tip_update_notification : g_last_block_tip_update_notification;
+ if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
return;
}