aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletmodel.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2020-04-02 07:42:01 -0400
committerRussell Yanofsky <russ@yanofsky.org>2020-05-01 06:59:09 -0400
commitbf0a510981ddc28c754881ca21c50ab18e5f2b59 (patch)
treeca23a8d61bb56a3f323fcfd2b65797b718da2404 /src/qt/walletmodel.cpp
parent2bc9b92ed8b7736ad67876398a0bb8287f57e9b3 (diff)
downloadbitcoin-bf0a510981ddc28c754881ca21c50ab18e5f2b59.tar.xz
gui: Avoid wallet tryGetBalances calls before TransactionChanged or BlockTip notifications
interfaces::Wallet::tryGetBalances was recently updated in https://github.com/bitcoin/bitcoin/pull/18160 to avoid computing balances internally, but this not efficient as it could be with #10102 because tryGetBalances is an interprocess call. Implementing the TransactionChanged / BlockTip check outside of tryGetBalances also allows tryGetBalances to be simplified in next commit 'Revert "gui: Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged"'.
Diffstat (limited to 'src/qt/walletmodel.cpp')
-rw-r--r--src/qt/walletmodel.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index e751f402cf..1789fefead 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -85,6 +85,10 @@ void WalletModel::updateStatus()
void WalletModel::pollBalanceChanged()
{
+ // Avoid recomputing wallet balances unless a TransactionChanged or
+ // BlockTip notification was received.
+ if (!fForceCheckBalanceChanged && cachedNumBlocks == m_client_model->getNumBlocks()) return;
+
// Try to get balances and return early if locks can't be acquired. This
// avoids the GUI from getting stuck on periodical polls if the core is
// holding the locks for a longer time - for example, during a wallet