aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-07-13 04:52:40 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-07-13 04:52:40 -0700
commit916b11fba5758fc7b5aa98a7bb78cfb22687c687 (patch)
treedec3cb69c9d2a085e5617ade23e24e5cf20b5a0f /src
parent771ffb5e28a75bf2a99283b3a9c7c40dc0f7907d (diff)
parent2e00b8fbd9138c03a11af9f7cb5418b57cd0ddb5 (diff)
downloadbitcoin-916b11fba5758fc7b5aa98a7bb78cfb22687c687.tar.xz
Merge pull request #1575 from laanwj/2012_07_persistentbalancecheck
(UI) Persistently poll for balance change when number of blocks changed
Diffstat (limited to 'src')
-rw-r--r--src/qt/walletmodel.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 0111e0cd91..3568616cd3 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -23,13 +23,10 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this);
- // This single-shot timer will be fired from the 'checkBalancedChanged'
- // method repeatedly while either of the unconfirmed or immature balances
- // are non-zero
+ // This timer will be fired repeatedly to update the balance
pollTimer = new QTimer(this);
- pollTimer->setInterval(MODEL_UPDATE_DELAY);
- pollTimer->setSingleShot(true);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged()));
+ pollTimer->start(MODEL_UPDATE_DELAY);
subscribeToCoreSignals();
}
@@ -74,13 +71,12 @@ void WalletModel::updateStatus()
void WalletModel::pollBalanceChanged()
{
- if(nBestHeight != cachedNumBlocks) {
+ if(nBestHeight != cachedNumBlocks)
+ {
+ // Balance and number of transactions might have changed
cachedNumBlocks = nBestHeight;
checkBalanceChanged();
}
-
- if(cachedUnconfirmedBalance || cachedImmatureBalance)
- pollTimer->start();
}
void WalletModel::checkBalanceChanged()
@@ -89,7 +85,8 @@ void WalletModel::checkBalanceChanged()
qint64 newUnconfirmedBalance = getUnconfirmedBalance();
qint64 newImmatureBalance = getImmatureBalance();
- if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) {
+ if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance)
+ {
cachedBalance = newBalance;
cachedUnconfirmedBalance = newUnconfirmedBalance;
cachedImmatureBalance = newImmatureBalance;
@@ -105,13 +102,11 @@ void WalletModel::updateTransaction(const QString &hash, int status)
// Balance and number of transactions might have changed
checkBalanceChanged();
- if(cachedUnconfirmedBalance || cachedImmatureBalance)
- pollTimer->start();
-
int newNumTransactions = getNumTransactions();
- if(cachedNumTransactions != newNumTransactions) {
- emit numTransactionsChanged(newNumTransactions);
+ if(cachedNumTransactions != newNumTransactions)
+ {
cachedNumTransactions = newNumTransactions;
+ emit numTransactionsChanged(newNumTransactions);
}
}