From 0933a37078e1ce3a3d70983c3e7f4b3ac6c3fa37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Sun, 16 Feb 2020 11:38:49 +0000 Subject: gui: Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged --- src/interfaces/wallet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/interfaces/wallet.cpp') diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index baea71d0bb..eeaf3d075d 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -380,16 +380,17 @@ public: } return result; } - bool tryGetBalances(WalletBalances& balances, int& num_blocks) override + bool tryGetBalances(WalletBalances& balances, int& num_blocks, bool force, int cached_num_blocks) override { auto locked_chain = m_wallet->chain().lock(true /* try_lock */); if (!locked_chain) return false; + num_blocks = locked_chain->getHeight().get_value_or(-1); + if (!force && num_blocks == cached_num_blocks) return false; TRY_LOCK(m_wallet->cs_wallet, locked_wallet); if (!locked_wallet) { return false; } balances = getBalances(); - num_blocks = locked_chain->getHeight().get_value_or(-1); return true; } CAmount getBalance() override { return m_wallet->GetBalance().m_mine_trusted; } -- cgit v1.2.3