mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-15 12:23:07 +02:00
qt: Make transaction notification queue wallet specific
Drop global vQueueNotifications and make one for each wallet.
This commit is contained in:
@ -78,9 +78,6 @@ private:
|
|||||||
bool showTransaction;
|
bool showTransaction;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool fQueueNotifications = false;
|
|
||||||
static std::vector< TransactionNotification > vQueueNotifications;
|
|
||||||
|
|
||||||
// Private implementation
|
// Private implementation
|
||||||
class TransactionTablePriv
|
class TransactionTablePriv
|
||||||
{
|
{
|
||||||
@ -98,6 +95,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
QList<TransactionRecord> cachedWallet;
|
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.
|
/* Query entire wallet anew from core.
|
||||||
*/
|
*/
|
||||||
void refreshWallet(interfaces::Wallet& wallet)
|
void refreshWallet(interfaces::Wallet& wallet)
|
||||||
@ -701,7 +704,7 @@ void TransactionTableModel::updateDisplayUnit()
|
|||||||
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
|
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
|
// Find transaction in wallet
|
||||||
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
|
// 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);
|
vQueueNotifications.push_back(notification);
|
||||||
return;
|
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)
|
if (nProgress == 0)
|
||||||
fQueueNotifications = true;
|
fQueueNotifications = true;
|
||||||
@ -726,17 +729,17 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
|
|||||||
{
|
{
|
||||||
fQueueNotifications = false;
|
fQueueNotifications = false;
|
||||||
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
|
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);
|
assert(invoked);
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
|
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
|
||||||
{
|
{
|
||||||
if (vQueueNotifications.size() - i <= 10) {
|
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);
|
assert(invoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
vQueueNotifications[i].invoke(ttm);
|
vQueueNotifications[i].invoke(parent);
|
||||||
}
|
}
|
||||||
std::vector<TransactionNotification >().swap(vQueueNotifications); // clear
|
std::vector<TransactionNotification >().swap(vQueueNotifications); // clear
|
||||||
}
|
}
|
||||||
@ -745,8 +748,8 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
|
|||||||
void TransactionTableModel::subscribeToCoreSignals()
|
void TransactionTableModel::subscribeToCoreSignals()
|
||||||
{
|
{
|
||||||
// Connect signals to wallet
|
// Connect signals to wallet
|
||||||
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(NotifyTransactionChanged, 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(ShowProgress, this, 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()
|
void TransactionTableModel::unsubscribeFromCoreSignals()
|
||||||
|
Reference in New Issue
Block a user