mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-07 15:17:25 -04:00
transaction: async commit
Addresses #2123, reduces UI freezing on long-lasting operation, improves Trezor experience
This commit is contained in:
@@ -496,6 +496,22 @@ bool Wallet::submitTxFile(const QString &fileName) const
|
||||
return m_walletImpl->importKeyImages(fileName.toStdString() + "_keyImages");
|
||||
}
|
||||
|
||||
void Wallet::commitTransactionAsync(PendingTransaction *t)
|
||||
{
|
||||
QStringList txid(t->txid());
|
||||
QFuture<bool> future = QtConcurrent::run(t, &PendingTransaction::commit);
|
||||
|
||||
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
||||
|
||||
connect(watcher, &QFutureWatcher<bool>::finished,
|
||||
this, [this, watcher, t, txid]() {
|
||||
QFuture<bool> future = watcher->future();
|
||||
watcher->deleteLater();
|
||||
emit transactionCommitted(future.result(), t, txid);
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
}
|
||||
|
||||
void Wallet::disposeTransaction(PendingTransaction *t)
|
||||
{
|
||||
m_walletImpl->disposeTransaction(t->m_pimpl);
|
||||
|
||||
@@ -213,6 +213,8 @@ public:
|
||||
//! Submit a transfer from file
|
||||
Q_INVOKABLE bool submitTxFile(const QString &fileName) const;
|
||||
|
||||
//! asynchronous transaction commit
|
||||
Q_INVOKABLE void commitTransactionAsync(PendingTransaction * t);
|
||||
|
||||
//! deletes transaction and frees memory
|
||||
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
||||
@@ -324,6 +326,7 @@ signals:
|
||||
void walletCreationHeightChanged();
|
||||
void deviceButtonRequest(quint64 buttonCode);
|
||||
void deviceButtonPressed();
|
||||
void transactionCommitted(bool status, PendingTransaction *t, QStringList txid);
|
||||
|
||||
// emitted when transaction is created async
|
||||
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
||||
|
||||
Reference in New Issue
Block a user