aboutsummaryrefslogtreecommitdiff
path: root/src/libwalletqt/Wallet.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-04-28 21:40:17 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-04-28 21:40:17 -0500
commit135c970ad94ca214b21440c849ba2f092925c7f1 (patch)
tree90f7aaa2f124c0f8e9dbf912a0a6aebdaf6e2520 /src/libwalletqt/Wallet.cpp
parentfd5d1f584eb28f710c83a2b674485fd7ad565c09 (diff)
parentcfdba59584d434e38407569441f4f518dd9507fa (diff)
downloadmonzero-gui-135c970ad94ca214b21440c849ba2f092925c7f1.tar.gz
monzero-gui-135c970ad94ca214b21440c849ba2f092925c7f1.tar.xz
monzero-gui-135c970ad94ca214b21440c849ba2f092925c7f1.zip
Merge pull request #2865
cfdba59 Wallet: implement async wallet storing (xiphon)
Diffstat (limited to 'src/libwalletqt/Wallet.cpp')
-rw-r--r--src/libwalletqt/Wallet.cpp15
1 files changed, 12 insertions, 3 deletions
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 <QtConcurrent/QtConcurrent>
#include <QList>
#include <QVector>
-#include <QMutex>
#include <QMutexLocker>
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)