From cfdba59584d434e38407569441f4f518dd9507fa Mon Sep 17 00:00:00 2001 From: xiphon Date: Sun, 26 Apr 2020 02:23:51 +0000 Subject: Wallet: implement async wallet storing --- src/libwalletqt/Wallet.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/libwalletqt/Wallet.cpp') diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 8eacb113..355ce6a9 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include namespace { @@ -230,9 +229,19 @@ QString Wallet::path() const return QDir::toNativeSeparators(QString::fromStdString(m_walletImpl->path())); } -bool Wallet::store(const QString &path) +void Wallet::storeAsync(const QJSValue &callback, const QString &path /* = "" */) { - return m_walletImpl->store(path.toStdString()); + const auto future = m_scheduler.run( + [this, path] { + QMutexLocker locker(&m_storeMutex); + + return QJSValueList({m_walletImpl->store(path.toStdString())}); + }, + callback); + if (!future.first) + { + QJSValue(callback).call(QJSValueList({false})); + } } bool Wallet::init(const QString &daemonAddress, bool trustedDaemon, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight) -- cgit v1.2.3