Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115466
D8896.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D8896.diff
View Options
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -198,8 +198,9 @@
//! Get balances.
virtual WalletBalances getBalances() = 0;
- //! Get balances if possible without blocking.
- virtual bool tryGetBalances(WalletBalances &balances, int &num_blocks) = 0;
+ //! Get balances if possible without waiting for chain and wallet locks.
+ virtual bool tryGetBalances(WalletBalances &balances, int &num_blocks,
+ bool force, int cached_num_blocks) = 0;
//! Get balance.
virtual Amount getBalance() = 0;
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -331,13 +331,16 @@
}
return result;
}
- bool tryGetBalances(WalletBalances &balances,
- int &num_blocks) override {
+ bool tryGetBalances(WalletBalances &balances, int &num_blocks,
+ bool force, int cached_num_blocks) override {
TRY_LOCK(m_wallet->cs_wallet, locked_wallet);
if (!locked_wallet) {
return false;
}
num_blocks = m_wallet->GetLastBlockHeight();
+ if (!force && num_blocks == cached_num_blocks) {
+ return false;
+ }
balances = getBalances();
return true;
}
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -69,20 +69,19 @@
// rescan.
interfaces::WalletBalances new_balances;
int numBlocks = -1;
- if (!m_wallet->tryGetBalances(new_balances, numBlocks)) {
+ if (!m_wallet->tryGetBalances(new_balances, numBlocks,
+ fForceCheckBalanceChanged, cachedNumBlocks)) {
return;
}
- if (fForceCheckBalanceChanged || numBlocks != cachedNumBlocks) {
- fForceCheckBalanceChanged = false;
+ fForceCheckBalanceChanged = false;
- // Balance and number of transactions might have changed
- cachedNumBlocks = numBlocks;
+ // Balance and number of transactions might have changed
+ cachedNumBlocks = numBlocks;
- checkBalanceChanged(new_balances);
- if (transactionTableModel) {
- transactionTableModel->updateConfirmations();
- }
+ checkBalanceChanged(new_balances);
+ if (transactionTableModel) {
+ transactionTableModel->updateConfirmations();
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:08 (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187518
Default Alt Text
D8896.diff (2 KB)
Attached To
D8896: gui: Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged
Event Timeline
Log In to Comment