| 275 | } |
| 276 | |
| 277 | static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_state, interfaces::BlockTip tip, double verificationProgress, bool fHeader) |
| 278 | { |
| 279 | if (fHeader) { |
| 280 | // cache best headers time and height to reduce future cs_main locks |
| 281 | clientmodel->cachedBestHeaderHeight = tip.block_height; |
| 282 | clientmodel->cachedBestHeaderTime = tip.block_time; |
| 283 | } else { |
| 284 | clientmodel->m_cached_num_blocks = tip.block_height; |
| 285 | WITH_LOCK(clientmodel->m_cached_tip_mutex, clientmodel->m_cached_tip_blocks = tip.block_hash;); |
| 286 | } |
| 287 | |
| 288 | // Throttle GUI notifications about (a) blocks during initial sync, and (b) both blocks and headers during reindex. |
| 289 | const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX; |
| 290 | const int64_t now = throttle ? GetTimeMillis() : 0; |
| 291 | int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification; |
| 292 | if (throttle && now < nLastUpdateNotification + count_milliseconds(MODEL_UPDATE_DELAY)) { |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | bool invoked = QMetaObject::invokeMethod(clientmodel, "numBlocksChanged", Qt::QueuedConnection, |
| 297 | Q_ARG(int, tip.block_height), |
| 298 | Q_ARG(QDateTime, QDateTime::fromSecsSinceEpoch(tip.block_time)), |
| 299 | Q_ARG(double, verificationProgress), |
| 300 | Q_ARG(bool, fHeader), |
| 301 | Q_ARG(SynchronizationState, sync_state)); |
| 302 | assert(invoked); |
| 303 | nLastUpdateNotification = now; |
| 304 | } |
| 305 | |
| 306 | void ClientModel::subscribeToCoreSignals() |
| 307 | { |
nothing calls this directly
no test coverage detected