diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2020-01-23 19:31:16 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2020-05-23 20:02:04 -0300 |
commit | 2f867203b0c7a4438ce484be4cfa2b29dbf1abf0 (patch) | |
tree | e8db2784b603a7c802625cef6db7d18b0a4236ad /src/qt/walletmodel.cpp | |
parent | cfe22a5f9e1d9e2d3dc8ce177e6c8eb04bc96615 (diff) | |
download | bitcoin-2f867203b0c7a4438ce484be4cfa2b29dbf1abf0.tar.xz |
Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals.
[ClientModel] best header/block hash cached.
Diffstat (limited to 'src/qt/walletmodel.cpp')
-rw-r--r-- | src/qt/walletmodel.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 1084ec9725..386002eaf2 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -46,7 +46,6 @@ WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel transactionTableModel(nullptr), recentRequestsTableModel(nullptr), cachedEncryptionStatus(Unencrypted), - cachedNumBlocks(0), timer(new QTimer(this)) { fHaveWatchOnly = m_wallet->haveWatchOnly(); @@ -88,24 +87,23 @@ void WalletModel::pollBalanceChanged() { // Avoid recomputing wallet balances unless a TransactionChanged or // BlockTip notification was received. - if (!fForceCheckBalanceChanged && cachedNumBlocks == m_client_model->getNumBlocks()) return; + if (!fForceCheckBalanceChanged && m_cached_last_update_tip == m_client_model->getBestBlockHash()) 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 // rescan. interfaces::WalletBalances new_balances; - int numBlocks = -1; - if (!m_wallet->tryGetBalances(new_balances, numBlocks)) { + uint256 block_hash; + if (!m_wallet->tryGetBalances(new_balances, block_hash)) { return; } - if(fForceCheckBalanceChanged || numBlocks != cachedNumBlocks) - { + if (fForceCheckBalanceChanged || block_hash != m_cached_last_update_tip) { fForceCheckBalanceChanged = false; // Balance and number of transactions might have changed - cachedNumBlocks = numBlocks; + m_cached_last_update_tip = block_hash; checkBalanceChanged(new_balances); if(transactionTableModel) |