diff options
| author | tobtoht <tob@featherwallet.org> | 2025-08-04 11:51:24 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2025-08-04 11:51:24 +0000 |
| commit | 8a85221f9576a7db1766150e5973940dd1fcf426 (patch) | |
| tree | 71c5a543eed50a0c244594afe3fb9028b5650dd4 /src/libwalletqt/Wallet.cpp | |
| parent | 10a184db8b242d4cff97e0f5845342cfccfc2042 (diff) | |
| parent | 5332495c2404ab4b102c98c22419e70143b1dc90 (diff) | |
| download | monzero-gui-8a85221f9576a7db1766150e5973940dd1fcf426.tar.gz monzero-gui-8a85221f9576a7db1766150e5973940dd1fcf426.tar.xz monzero-gui-8a85221f9576a7db1766150e5973940dd1fcf426.zip | |
Merge pull request #4050
5332495 Implement background sync when locked (j-berman)
Diffstat (limited to 'src/libwalletqt/Wallet.cpp')
| -rw-r--r-- | src/libwalletqt/Wallet.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index cec4ff63..a5ac6925 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -529,6 +529,69 @@ bool Wallet::scanTransactions(const QVector<QString> &txids) return m_walletImpl->scanTransactions(c); } +void Wallet::setupBackgroundSync(const Wallet::BackgroundSyncType background_sync_type, const QString &wallet_password) +{ + qDebug() << "Setting up background sync"; + bool refreshEnabled = m_refreshEnabled; + pauseRefresh(); + + // run inside scheduler because of lag when stopping/starting refresh + m_scheduler.run([this, refreshEnabled, background_sync_type, &wallet_password] { + m_walletImpl->setupBackgroundSync( + static_cast<Monero::Wallet::BackgroundSyncType>(background_sync_type), + wallet_password.toStdString(), + Monero::optional<std::string>()); + if (refreshEnabled) + startRefresh(); + emit backgroundSyncSetup(); + }); +} + +Wallet::BackgroundSyncType Wallet::getBackgroundSyncType() const +{ + return static_cast<BackgroundSyncType>(m_walletImpl->getBackgroundSyncType()); +} + +bool Wallet::isBackgroundWallet() const +{ + return m_walletImpl->isBackgroundWallet(); +} + +bool Wallet::isBackgroundSyncing() const +{ + return m_walletImpl->isBackgroundSyncing(); +} + +void Wallet::startBackgroundSync() +{ + qDebug() << "Starting background sync"; + bool refreshEnabled = m_refreshEnabled; + pauseRefresh(); + + // run inside scheduler because of lag when stopping/starting refresh + m_scheduler.run([this, refreshEnabled] { + m_walletImpl->startBackgroundSync(); + if (refreshEnabled) + startRefresh(); + emit backgroundSyncStarted(); + }); +} + +void Wallet::stopBackgroundSync(const QString &password) +{ + qDebug() << "Stopping background sync"; + bool refreshEnabled = m_refreshEnabled; + pauseRefresh(); + + // run inside scheduler because of lag when stopping/starting refresh + m_scheduler.run([this, password, refreshEnabled] { + m_walletImpl->stopBackgroundSync(password.toStdString()); + if (refreshEnabled) + startRefresh(); + emit backgroundSyncStopped(); + }); +} + bool Wallet::refresh(bool historyAndSubaddresses /* = true */) { refreshingSet(true); |
