aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2018-08-01 13:38:45 -0400
committerRussell Yanofsky <russ@yanofsky.org>2020-01-09 16:05:35 -0400
commit96cb597325f64cadb3cf43e2cdb3d7c1e2e49891 (patch)
tree8541d0f8d1c98dfaf761382f1c1379533a108040 /src/qt/clientmodel.cpp
parente7f84503571c171a7e6728cd2d77dd4103bd7a6f (diff)
downloadbitcoin-96cb597325f64cadb3cf43e2cdb3d7c1e2e49891.tar.xz
gui: Avoid redundant tx status updates
In TransactionTablePriv::index, avoid calling interfaces::Wallet::tryGetTxStatus if the status is up to date as of the most recent NotifyBlockTip notification. Store height from the most recent notification in a new ClientModel::cachedNumBlocks variable in order to check this. This avoids floods of IPC traffic from tryGetTxStatus with #10102 when there are a lot of transactions. It might also make the GUI a little more efficient even when there is no IPC.
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index e8146982f9..f0046c9d7c 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -105,6 +105,14 @@ int64_t ClientModel::getHeaderTipTime() const
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)
{
Q_EMIT numConnectionsChanged(numConnections);
@@ -241,6 +249,8 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig
// cache best headers time and height to reduce future cs_main locks
clientmodel->cachedBestHeaderHeight = height;
clientmodel->cachedBestHeaderTime = blockTime;
+ } else {
+ clientmodel->m_cached_num_blocks = height;
}
// if we are in-sync or if we notify a header update, update the UI regardless of last update time
if (fHeader || !initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {