aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-10-28 00:31:58 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-10-28 00:35:17 +0000
commit989e579d07bb5031639060b717f7a0be15d10e29 (patch)
tree2923e4bad5c5e49561e8d5929e43afc121ffe4a6 /src
parent7b3b2303f44031c3545651858f697a495c3ea37a (diff)
qt: Make transaction notification queue wallet specific
Drop global vQueueNotifications and make one for each wallet.
Diffstat (limited to 'src')
-rw-r--r--src/qt/transactiontablemodel.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 928a06ecbb..0719613398 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -78,9 +78,6 @@ private:
bool showTransaction;
};
-static bool fQueueNotifications = false;
-static std::vector< TransactionNotification > vQueueNotifications;
-
// Private implementation
class TransactionTablePriv
{
@@ -98,6 +95,12 @@ public:
*/
QList<TransactionRecord> cachedWallet;
+ bool fQueueNotifications = false;
+ std::vector< TransactionNotification > vQueueNotifications;
+
+ void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
+ void ShowProgress(const std::string &title, int nProgress);
+
/* Query entire wallet anew from core.
*/
void refreshWallet(interfaces::Wallet& wallet)
@@ -701,7 +704,7 @@ void TransactionTableModel::updateDisplayUnit()
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
}
-static void NotifyTransactionChanged(TransactionTableModel *ttm, const uint256 &hash, ChangeType status)
+void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)
{
// Find transaction in wallet
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
@@ -714,10 +717,10 @@ static void NotifyTransactionChanged(TransactionTableModel *ttm, const uint256 &
vQueueNotifications.push_back(notification);
return;
}
- notification.invoke(ttm);
+ notification.invoke(parent);
}
-static void ShowProgress(TransactionTableModel *ttm, const std::string &title, int nProgress)
+void TransactionTablePriv::ShowProgress(const std::string &title, int nProgress)
{
if (nProgress == 0)
fQueueNotifications = true;
@@ -726,17 +729,17 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
{
fQueueNotifications = false;
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
- bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
+ bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
assert(invoked);
}
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
{
if (vQueueNotifications.size() - i <= 10) {
- bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
+ bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
assert(invoked);
}
- vQueueNotifications[i].invoke(ttm);
+ vQueueNotifications[i].invoke(parent);
}
std::vector<TransactionNotification >().swap(vQueueNotifications); // clear
}
@@ -745,8 +748,8 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
void TransactionTableModel::subscribeToCoreSignals()
{
// Connect signals to wallet
- m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
- m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
+ m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(&TransactionTablePriv::NotifyTransactionChanged, priv, std::placeholders::_1, std::placeholders::_2));
+ m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(&TransactionTablePriv::ShowProgress, priv, std::placeholders::_1, std::placeholders::_2));
}
void TransactionTableModel::unsubscribeFromCoreSignals()