aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactiontablemodel.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-10 16:32:12 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-04-10 16:34:30 -0400
commit3eb8b1c3924c1d14c1a4234eb5360f32808b86dc (patch)
tree1d540ee7bb9c1fdd97f9c0785ceda74c9e34dc6f /src/qt/transactiontablemodel.cpp
parent75917591c840ca61f5e2c6f5858e6882e834a911 (diff)
parent96cb597325f64cadb3cf43e2cdb3d7c1e2e49891 (diff)
downloadbitcoin-3eb8b1c3924c1d14c1a4234eb5360f32808b86dc.tar.xz
Merge #17905: gui: Avoid redundant tx status updates
96cb597325f64cadb3cf43e2cdb3d7c1e2e49891 gui: Avoid redundant tx status updates (Russell Yanofsky) Pull request description: This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). 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. ACKs for top commit: promag: Code review ACK 96cb597325f64cadb3cf43e2cdb3d7c1e2e49891. hebasto: ACK 96cb597325f64cadb3cf43e2cdb3d7c1e2e49891 Tree-SHA512: fce597bf52a813ad4923110d0a39229ea09e1631e0d580ea18cffb09e58cdbb4b111a40a9a9270ff16d8163cd47b0bd9f1fe7e3a6c7ebb19198f049f8dd1aa46
Diffstat (limited to 'src/qt/transactiontablemodel.cpp')
-rw-r--r--src/qt/transactiontablemodel.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 64e9c856db..18554aef1f 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -5,6 +5,7 @@
#include <qt/transactiontablemodel.h>
#include <qt/addresstablemodel.h>
+#include <qt/clientmodel.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/optionsmodel.h>
@@ -175,7 +176,7 @@ public:
return cachedWallet.size();
}
- TransactionRecord *index(interfaces::Wallet& wallet, int idx)
+ TransactionRecord *index(interfaces::Wallet& wallet, const int cur_num_blocks, const int idx)
{
if(idx >= 0 && idx < cachedWallet.size())
{
@@ -191,7 +192,7 @@ public:
interfaces::WalletTxStatus wtx;
int numBlocks;
int64_t block_time;
- if (wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time) && rec->statusUpdateNeeded(numBlocks)) {
+ if (rec->statusUpdateNeeded(cur_num_blocks) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
rec->updateStatus(wtx, numBlocks, block_time);
}
return rec;
@@ -663,10 +664,10 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
- TransactionRecord *data = priv->index(walletModel->wallet(), row);
+ TransactionRecord *data = priv->index(walletModel->wallet(), walletModel->clientModel().getNumBlocks(), row);
if(data)
{
- return createIndex(row, column, priv->index(walletModel->wallet(), row));
+ return createIndex(row, column, data);
}
return QModelIndex();
}