Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletmodel.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
void WalletModel::pollBalanceChanged() { | void WalletModel::pollBalanceChanged() { | ||||
// Try to get balances and return early if locks can't be acquired. This | // 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 | // 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 | // holding the locks for a longer time - for example, during a wallet | ||||
// rescan. | // rescan. | ||||
interfaces::WalletBalances new_balances; | interfaces::WalletBalances new_balances; | ||||
int numBlocks = -1; | int numBlocks = -1; | ||||
if (!m_wallet->tryGetBalances(new_balances, numBlocks)) { | if (!m_wallet->tryGetBalances(new_balances, numBlocks, | ||||
fForceCheckBalanceChanged, cachedNumBlocks)) { | |||||
return; | return; | ||||
} | } | ||||
if (fForceCheckBalanceChanged || numBlocks != cachedNumBlocks) { | |||||
fForceCheckBalanceChanged = false; | fForceCheckBalanceChanged = false; | ||||
// Balance and number of transactions might have changed | // Balance and number of transactions might have changed | ||||
cachedNumBlocks = numBlocks; | cachedNumBlocks = numBlocks; | ||||
checkBalanceChanged(new_balances); | checkBalanceChanged(new_balances); | ||||
if (transactionTableModel) { | if (transactionTableModel) { | ||||
transactionTableModel->updateConfirmations(); | transactionTableModel->updateConfirmations(); | ||||
} | } | ||||
} | } | ||||
} | |||||
void WalletModel::checkBalanceChanged( | void WalletModel::checkBalanceChanged( | ||||
const interfaces::WalletBalances &new_balances) { | const interfaces::WalletBalances &new_balances) { | ||||
if (new_balances.balanceChanged(m_cached_balances)) { | if (new_balances.balanceChanged(m_cached_balances)) { | ||||
m_cached_balances = new_balances; | m_cached_balances = new_balances; | ||||
Q_EMIT balanceChanged(new_balances); | Q_EMIT balanceChanged(new_balances); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 428 Lines • Show Last 20 Lines |