qt: Move transaction notification to transaction table model
Move transaction new/update notification to TransactionTableModel. This moves the concerns to where they're actually handled. No need to bounce this through wallet model. - Do wallet transaction preprocessing on signal handler side; avoids locking cs_main/cs_wallet on notification in GUI thread (except for new transactions)
This commit is contained in:
@@ -34,7 +34,6 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
|
||||
cachedEncryptionStatus(Unencrypted),
|
||||
cachedNumBlocks(0)
|
||||
{
|
||||
fProcessingQueuedTransactions = false;
|
||||
fHaveWatchOnly = wallet->HaveWatchOnly();
|
||||
fForceCheckBalanceChanged = false;
|
||||
|
||||
@@ -164,11 +163,8 @@ void WalletModel::checkBalanceChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void WalletModel::updateTransaction(const QString &hash, int status)
|
||||
void WalletModel::updateTransaction()
|
||||
{
|
||||
if(transactionTableModel)
|
||||
transactionTableModel->updateTransaction(hash, status);
|
||||
|
||||
// Balance and number of transactions might have changed
|
||||
fForceCheckBalanceChanged = true;
|
||||
}
|
||||
@@ -455,45 +451,16 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
|
||||
Q_ARG(int, status));
|
||||
}
|
||||
|
||||
// queue notifications to show a non freezing progress dialog e.g. for rescan
|
||||
static bool fQueueNotifications = false;
|
||||
static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications;
|
||||
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
|
||||
{
|
||||
if (fQueueNotifications)
|
||||
{
|
||||
vQueueNotifications.push_back(make_pair(hash, status));
|
||||
return;
|
||||
}
|
||||
|
||||
QString strHash = QString::fromStdString(hash.GetHex());
|
||||
|
||||
qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
|
||||
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection,
|
||||
Q_ARG(QString, strHash),
|
||||
Q_ARG(int, status));
|
||||
Q_UNUSED(wallet);
|
||||
Q_UNUSED(hash);
|
||||
Q_UNUSED(status);
|
||||
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
|
||||
{
|
||||
if (nProgress == 0)
|
||||
fQueueNotifications = true;
|
||||
|
||||
if (nProgress == 100)
|
||||
{
|
||||
fQueueNotifications = false;
|
||||
if (vQueueNotifications.size() > 10) // prevent balloon spam, show maximum 10 balloons
|
||||
QMetaObject::invokeMethod(walletmodel, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
|
||||
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
|
||||
{
|
||||
if (vQueueNotifications.size() - i <= 10)
|
||||
QMetaObject::invokeMethod(walletmodel, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||
|
||||
NotifyTransactionChanged(walletmodel, NULL, vQueueNotifications[i].first, vQueueNotifications[i].second);
|
||||
}
|
||||
std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear
|
||||
}
|
||||
|
||||
// emits signal "showProgress"
|
||||
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
|
||||
Q_ARG(QString, QString::fromStdString(title)),
|
||||
|
||||
Reference in New Issue
Block a user