[Qt] Call checkBalanceChanged() periodically instead for every updated transaction
This commit is contained in:
parent
f30801afbd
commit
80daee0fb5
@ -36,6 +36,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
|
|||||||
{
|
{
|
||||||
fProcessingQueuedTransactions = false;
|
fProcessingQueuedTransactions = false;
|
||||||
fHaveWatchOnly = wallet->HaveWatchOnly();
|
fHaveWatchOnly = wallet->HaveWatchOnly();
|
||||||
|
fForceCheckBalanceChanged = false;
|
||||||
|
|
||||||
addressTableModel = new AddressTableModel(wallet, this);
|
addressTableModel = new AddressTableModel(wallet, this);
|
||||||
transactionTableModel = new TransactionTableModel(wallet, this);
|
transactionTableModel = new TransactionTableModel(wallet, this);
|
||||||
@ -121,8 +122,10 @@ void WalletModel::pollBalanceChanged()
|
|||||||
if(!lockWallet)
|
if(!lockWallet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(chainActive.Height() != cachedNumBlocks)
|
if(fForceCheckBalanceChanged || chainActive.Height() != cachedNumBlocks)
|
||||||
{
|
{
|
||||||
|
fForceCheckBalanceChanged = false;
|
||||||
|
|
||||||
// Balance and number of transactions might have changed
|
// Balance and number of transactions might have changed
|
||||||
cachedNumBlocks = chainActive.Height();
|
cachedNumBlocks = chainActive.Height();
|
||||||
|
|
||||||
@ -167,7 +170,7 @@ void WalletModel::updateTransaction(const QString &hash, int status)
|
|||||||
transactionTableModel->updateTransaction(hash, status);
|
transactionTableModel->updateTransaction(hash, status);
|
||||||
|
|
||||||
// Balance and number of transactions might have changed
|
// Balance and number of transactions might have changed
|
||||||
checkBalanceChanged();
|
fForceCheckBalanceChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletModel::updateAddressBook(const QString &address, const QString &label,
|
void WalletModel::updateAddressBook(const QString &address, const QString &label,
|
||||||
@ -344,6 +347,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
|||||||
}
|
}
|
||||||
emit coinsSent(wallet, rcp, transaction_array);
|
emit coinsSent(wallet, rcp, transaction_array);
|
||||||
}
|
}
|
||||||
|
checkBalanceChanged(); // update balance immediately, otherwise there could be a short noticeable delay until pollBalanceChanged hits
|
||||||
|
|
||||||
return SendCoinsReturn(OK);
|
return SendCoinsReturn(OK);
|
||||||
}
|
}
|
||||||
@ -473,11 +477,6 @@ static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet,
|
|||||||
|
|
||||||
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
|
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
|
||||||
{
|
{
|
||||||
// emits signal "showProgress"
|
|
||||||
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
|
|
||||||
Q_ARG(QString, QString::fromStdString(title)),
|
|
||||||
Q_ARG(int, nProgress));
|
|
||||||
|
|
||||||
if (nProgress == 0)
|
if (nProgress == 0)
|
||||||
fQueueNotifications = true;
|
fQueueNotifications = true;
|
||||||
|
|
||||||
@ -495,6 +494,11 @@ static void ShowProgress(WalletModel *walletmodel, const std::string &title, int
|
|||||||
}
|
}
|
||||||
std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear
|
std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// emits signal "showProgress"
|
||||||
|
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
|
||||||
|
Q_ARG(QString, QString::fromStdString(title)),
|
||||||
|
Q_ARG(int, nProgress));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
|
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
|
||||||
|
@ -199,6 +199,7 @@ private:
|
|||||||
CWallet *wallet;
|
CWallet *wallet;
|
||||||
bool fProcessingQueuedTransactions;
|
bool fProcessingQueuedTransactions;
|
||||||
bool fHaveWatchOnly;
|
bool fHaveWatchOnly;
|
||||||
|
bool fForceCheckBalanceChanged;
|
||||||
|
|
||||||
// Wallet has an options model for wallet-specific options
|
// Wallet has an options model for wallet-specific options
|
||||||
// (transaction fee, for example)
|
// (transaction fee, for example)
|
||||||
|
Loading…
Reference in New Issue
Block a user