Skip to content

Commit 33d520a

Browse files
committed
refactor, qt: Use std::chrono for MODEL_UPDATE_DELAY constant
1 parent 2e01b69 commit 33d520a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/qt/clientmodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <netbase.h>
1818
#include <util/system.h>
1919
#include <util/threadnames.h>
20+
#include <util/time.h>
2021
#include <validation.h>
2122

2223
#include <stdint.h>
@@ -288,7 +289,7 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_
288289
const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX;
289290
const int64_t now = throttle ? GetTimeMillis() : 0;
290291
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
291-
if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
292+
if (throttle && now < nLastUpdateNotification + count_milliseconds(MODEL_UPDATE_DELAY)) {
292293
return;
293294
}
294295

src/qt/guiconstants.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
#ifndef BITCOIN_QT_GUICONSTANTS_H
66
#define BITCOIN_QT_GUICONSTANTS_H
77

8+
#include <chrono>
89
#include <cstdint>
910

10-
/* Milliseconds between model updates */
11-
static const int MODEL_UPDATE_DELAY = 250;
11+
using namespace std::chrono_literals;
12+
13+
/* A delay between model updates */
14+
static constexpr auto MODEL_UPDATE_DELAY{250ms};
1215

1316
/* AskPassphraseDialog -- Maximum passphrase length */
1417
static const int MAX_PASSPHRASE_SIZE = 1024;

0 commit comments

Comments
 (0)