@@ -237,17 +237,6 @@ static void BannedListChanged(ClientModel *clientmodel)
237
237
238
238
static void BlockTipChanged (ClientModel* clientmodel, SynchronizationState sync_state, int height, int64_t blockTime, double verificationProgress, bool fHeader )
239
239
{
240
- const bool initialSync = sync_state != SynchronizationState::POST_INIT;
241
-
242
- // lock free async UI updates in case we have a new block tip
243
- // during initial sync, only update the UI if the last update
244
- // was > 250ms (MODEL_UPDATE_DELAY) ago
245
- int64_t now = 0 ;
246
- if (initialSync)
247
- now = GetTimeMillis ();
248
-
249
- int64_t & nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
250
-
251
240
if (fHeader ) {
252
241
// cache best headers time and height to reduce future cs_main locks
253
242
clientmodel->cachedBestHeaderHeight = height;
@@ -256,17 +245,21 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_
256
245
clientmodel->m_cached_num_blocks = height;
257
246
}
258
247
259
- // During initial sync, block notifications, and header notifications from reindexing are both throttled.
260
- if (!initialSync || (fHeader && !clientmodel->node ().getReindex ()) || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
261
- // pass an async signal to the UI thread
262
- bool invoked = QMetaObject::invokeMethod (clientmodel, " numBlocksChanged" , Qt::QueuedConnection,
263
- Q_ARG (int , height),
264
- Q_ARG (QDateTime, QDateTime::fromTime_t (blockTime)),
265
- Q_ARG (double , verificationProgress),
266
- Q_ARG (bool , fHeader ));
267
- assert (invoked);
268
- nLastUpdateNotification = now;
248
+ // Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex.
249
+ const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader ) || sync_state == SynchronizationState::INIT_REINDEX;
250
+ const int64_t now = throttle ? GetTimeMillis () : 0 ;
251
+ int64_t & nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
252
+ if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
253
+ return ;
269
254
}
255
+
256
+ bool invoked = QMetaObject::invokeMethod (clientmodel, " numBlocksChanged" , Qt::QueuedConnection,
257
+ Q_ARG (int , height),
258
+ Q_ARG (QDateTime, QDateTime::fromTime_t (blockTime)),
259
+ Q_ARG (double , verificationProgress),
260
+ Q_ARG (bool , fHeader ));
261
+ assert (invoked);
262
+ nLastUpdateNotification = now;
270
263
}
271
264
272
265
void ClientModel::subscribeToCoreSignals ()
0 commit comments