transaction: async commit

Addresses #2123, reduces UI freezing on long-lasting operation, improves Trezor experience
This commit is contained in:
Dusan Klinec
2019-05-02 10:11:43 +02:00
parent 97cd215491
commit c88bb60135
3 changed files with 29 additions and 11 deletions

View File

@@ -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);