refactor: Remove Node::getReindex() call from GUI
This commit is contained in:
1 file changed
+14
-21
+14
-21
@@ -237,17 +237,6 @@ static void BannedListChanged(ClientModel *clientmodel)
|
|||||||
|
|
||||||
static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, int height, int64_t blockTime, double verificationProgress, bool fHeader)
|
static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, int height, int64_t blockTime, double verificationProgress, bool fHeader)
|
||||||
{
|
{
|
||||||
const bool initialSync = sync_state != SynchronizationState::POST_INIT;
|
|
||||||
|
|
||||||
// lock free async UI updates in case we have a new block tip
|
|
||||||
// during initial sync, only update the UI if the last update
|
|
||||||
// was > 250ms (MODEL_UPDATE_DELAY) ago
|
|
||||||
int64_t now = 0;
|
|
||||||
if (initialSync)
|
|
||||||
now = GetTimeMillis();
|
|
||||||
|
|
||||||
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
|
||||||
|
|
||||||
if (fHeader) {
|
if (fHeader) {
|
||||||
// cache best headers time and height to reduce future cs_main locks
|
// cache best headers time and height to reduce future cs_main locks
|
||||||
clientmodel->cachedBestHeaderHeight = height;
|
clientmodel->cachedBestHeaderHeight = height;
|
||||||
@@ -256,17 +245,21 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_
|
|||||||
clientmodel->m_cached_num_blocks = height;
|
clientmodel->m_cached_num_blocks = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// During initial sync, block notifications, and header notifications from reindexing are both throttled.
|
// Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex.
|
||||||
if (!initialSync || (fHeader && !clientmodel->node().getReindex()) || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
|
const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX;
|
||||||
//pass an async signal to the UI thread
|
const int64_t now = throttle ? GetTimeMillis() : 0;
|
||||||
bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
||||||
Q_ARG(int, height),
|
if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
|
||||||
Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)),
|
return;
|
||||||
Q_ARG(double, verificationProgress),
|
|
||||||
Q_ARG(bool, fHeader));
|
|
||||||
assert(invoked);
|
|
||||||
nLastUpdateNotification = now;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection,
|
||||||
|
Q_ARG(int, height),
|
||||||
|
Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)),
|
||||||
|
Q_ARG(double, verificationProgress),
|
||||||
|
Q_ARG(bool, fHeader));
|
||||||
|
assert(invoked);
|
||||||
|
nLastUpdateNotification = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientModel::subscribeToCoreSignals()
|
void ClientModel::subscribeToCoreSignals()
|
||||||
|
|||||||
Reference in new issue
Block a user