Skip to content

Commit bf0a510

Browse files
committed
gui: Avoid wallet tryGetBalances calls before TransactionChanged or BlockTip notifications
interfaces::Wallet::tryGetBalances was recently updated in bitcoin/bitcoin#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"'.
1 parent 2bc9b92 commit bf0a510

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/qt/walletmodel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ void WalletModel::updateStatus()
8585

8686
void WalletModel::pollBalanceChanged()
8787
{
88+
// Avoid recomputing wallet balances unless a TransactionChanged or
89+
// BlockTip notification was received.
90+
if (!fForceCheckBalanceChanged && cachedNumBlocks == m_client_model->getNumBlocks()) return;
91+
8892
// Try to get balances and return early if locks can't be acquired. This
8993
// avoids the GUI from getting stuck on periodical polls if the core is
9094
// holding the locks for a longer time - for example, during a wallet

0 commit comments

Comments
 (0)