Changeset View
Changeset View
Standalone View
Standalone View
src/qt/clientmodel.cpp
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if (cachedBestHeaderTime == -1) { | ||||
if (m_node.getHeaderTip(height, blockTime)) { | if (m_node.getHeaderTip(height, blockTime)) { | ||||
cachedBestHeaderHeight = height; | cachedBestHeaderHeight = height; | ||||
cachedBestHeaderTime = blockTime; | cachedBestHeaderTime = blockTime; | ||||
} | } | ||||
} | } | ||||
return cachedBestHeaderTime; | return cachedBestHeaderTime; | ||||
} | } | ||||
int ClientModel::getNumBlocks() const { | |||||
if (m_cached_num_blocks == -1) { | |||||
m_cached_num_blocks = m_node.getNumBlocks(); | |||||
} | |||||
return m_cached_num_blocks; | |||||
} | |||||
void ClientModel::updateNumConnections(int numConnections) { | void ClientModel::updateNumConnections(int numConnections) { | ||||
Q_EMIT numConnectionsChanged(numConnections); | Q_EMIT numConnectionsChanged(numConnections); | ||||
} | } | ||||
void ClientModel::updateNetworkActive(bool networkActive) { | void ClientModel::updateNetworkActive(bool networkActive) { | ||||
Q_EMIT networkActiveChanged(networkActive); | Q_EMIT networkActiveChanged(networkActive); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
static void BlockTipChanged(ClientModel *clientmodel, | static void BlockTipChanged(ClientModel *clientmodel, | ||||
SynchronizationState sync_state, int height, | SynchronizationState sync_state, int height, | ||||
int64_t blockTime, double verificationProgress, | int64_t blockTime, double verificationProgress, | ||||
bool fHeader) { | bool fHeader) { | ||||
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; | ||||
clientmodel->cachedBestHeaderTime = blockTime; | clientmodel->cachedBestHeaderTime = blockTime; | ||||
} else { | |||||
clientmodel->m_cached_num_blocks = height; | |||||
} | } | ||||
// Throttle GUI notifications about (a) blocks during initial sync, and (b) | // Throttle GUI notifications about (a) blocks during initial sync, and (b) | ||||
// both blocks and headers during reindex. | // both blocks and headers during reindex. | ||||
const bool throttle = | const bool throttle = | ||||
(sync_state != SynchronizationState::POST_INIT && !fHeader) || | (sync_state != SynchronizationState::POST_INIT && !fHeader) || | ||||
sync_state == SynchronizationState::INIT_REINDEX; | sync_state == SynchronizationState::INIT_REINDEX; | ||||
const int64_t now = throttle ? GetTimeMillis() : 0; | const int64_t now = throttle ? GetTimeMillis() : 0; | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |