mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-28 12:50:17 +02:00
qt: Use steady clock to throttle GUI notifications
This commit is contained in:
parent
fa1d8044ab
commit
fa97621804
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user