aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDusan Klinec <dusan.klinec@gmail.com>2019-05-02 10:11:43 +0200
committerDusan Klinec <dusan.klinec@gmail.com>2019-05-02 16:19:22 +0200
commitc88bb60135226dc889e51ad5a494d4bd600662b6 (patch)
tree9afb5f50b5257e8ba0d0a0f5486482a011346569 /src
parent97cd215491a44c753ee1450712b3b8d93efdcc37 (diff)
downloadmonzero-gui-c88bb60135226dc889e51ad5a494d4bd600662b6.tar.gz
monzero-gui-c88bb60135226dc889e51ad5a494d4bd600662b6.tar.xz
monzero-gui-c88bb60135226dc889e51ad5a494d4bd600662b6.zip
transaction: async commit
Addresses #2123, reduces UI freezing on long-lasting operation, improves Trezor experience
Diffstat (limited to 'src')
-rw-r--r--src/libwalletqt/Wallet.cpp16
-rw-r--r--src/libwalletqt/Wallet.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp
index 0c320842..17b391a6 100644
--- a/src/libwalletqt/Wallet.cpp
+++ b/src/libwalletqt/Wallet.cpp
@@ -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);
diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h
index 2866c9fd..d8f660e5 100644
--- a/src/libwalletqt/Wallet.h
+++ b/src/libwalletqt/Wallet.h
@@ -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);