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.
This commit is contained in:
Russell Yanofsky
2018-08-01 13:38:45 -04:00
parent e7f8450357
commit 96cb597325
10 changed files with 46 additions and 16 deletions

View File

@@ -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();
}