Skip to content

Commit 989e579

Browse files
committed
qt: Make transaction notification queue wallet specific
Drop global vQueueNotifications and make one for each wallet.
1 parent 7b3b230 commit 989e579

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/qt/transactiontablemodel.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ struct TransactionNotification
7878
bool showTransaction;
7979
};
8080

81-
static bool fQueueNotifications = false;
82-
static std::vector< TransactionNotification > vQueueNotifications;
83-
8481
// Private implementation
8582
class TransactionTablePriv
8683
{
@@ -98,6 +95,12 @@ class TransactionTablePriv
9895
*/
9996
QList<TransactionRecord> cachedWallet;
10097

98+
bool fQueueNotifications = false;
99+
std::vector< TransactionNotification > vQueueNotifications;
100+
101+
void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
102+
void ShowProgress(const std::string &title, int nProgress);
103+
101104
/* Query entire wallet anew from core.
102105
*/
103106
void refreshWallet(interfaces::Wallet& wallet)
@@ -701,7 +704,7 @@ void TransactionTableModel::updateDisplayUnit()
701704
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
702705
}
703706

704-
static void NotifyTransactionChanged(TransactionTableModel *ttm, const uint256 &hash, ChangeType status)
707+
void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)
705708
{
706709
// Find transaction in wallet
707710
// 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 &
714717
vQueueNotifications.push_back(notification);
715718
return;
716719
}
717-
notification.invoke(ttm);
720+
notification.invoke(parent);
718721
}
719722

720-
static void ShowProgress(TransactionTableModel *ttm, const std::string &title, int nProgress)
723+
void TransactionTablePriv::ShowProgress(const std::string &title, int nProgress)
721724
{
722725
if (nProgress == 0)
723726
fQueueNotifications = true;
@@ -726,17 +729,17 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
726729
{
727730
fQueueNotifications = false;
728731
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
729-
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
732+
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
730733
assert(invoked);
731734
}
732735
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
733736
{
734737
if (vQueueNotifications.size() - i <= 10) {
735-
bool invoked = QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
738+
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
736739
assert(invoked);
737740
}
738741

739-
vQueueNotifications[i].invoke(ttm);
742+
vQueueNotifications[i].invoke(parent);
740743
}
741744
std::vector<TransactionNotification >().swap(vQueueNotifications); // clear
742745
}
@@ -745,8 +748,8 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
745748
void TransactionTableModel::subscribeToCoreSignals()
746749
{
747750
// Connect signals to wallet
748-
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
749-
m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2));
751+
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(&TransactionTablePriv::NotifyTransactionChanged, priv, std::placeholders::_1, std::placeholders::_2));
752+
m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(&TransactionTablePriv::ShowProgress, priv, std::placeholders::_1, std::placeholders::_2));
750753
}
751754

752755
void TransactionTableModel::unsubscribeFromCoreSignals()

0 commit comments

Comments
 (0)