Skip to content

Commit

Permalink
gui: Avoid wallet tryGetBalances calls before TransactionChanged or B…
Browse files Browse the repository at this point in the history
…lockTip notifications

interfaces::Wallet::tryGetBalances was recently updated in
bitcoin#18160 to avoid computing balances
internally, but this not efficient as it could be with bitcoin#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"'.
  • Loading branch information
ryanofsky committed May 1, 2020
1 parent 2bc9b92 commit bf0a510
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf0a510

Please sign in to comment.