From c88bb60135226dc889e51ad5a494d4bd600662b6 Mon Sep 17 00:00:00 2001 From: Dusan Klinec Date: Thu, 2 May 2019 10:11:43 +0200 Subject: transaction: async commit Addresses #2123, reduces UI freezing on long-lasting operation, improves Trezor experience --- src/libwalletqt/Wallet.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libwalletqt/Wallet.cpp') 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 future = QtConcurrent::run(t, &PendingTransaction::commit); + + QFutureWatcher * watcher = new QFutureWatcher(); + + connect(watcher, &QFutureWatcher::finished, + this, [this, watcher, t, txid]() { + QFuture 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); -- cgit v1.2.3