mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 11:52:05 +02:00
Merge pull request #3268
cebb789
Wallet: fix initialization flag handling (xiphon)
This commit is contained in:
commit
79f2843b09
@ -104,10 +104,7 @@ void Wallet::updateConnectionStatusAsync()
|
|||||||
setConnectionStatus(ConnectionStatus_Connecting);
|
setConnectionStatus(ConnectionStatus_Connecting);
|
||||||
}
|
}
|
||||||
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
||||||
if (newStatus != m_connectionStatus || !m_initialized) {
|
setConnectionStatus(newStatus);
|
||||||
m_initialized = true;
|
|
||||||
setConnectionStatus(newStatus);
|
|
||||||
}
|
|
||||||
// Release lock
|
// Release lock
|
||||||
m_connectionStatusRunning = false;
|
m_connectionStatusRunning = false;
|
||||||
});
|
});
|
||||||
@ -115,8 +112,13 @@ void Wallet::updateConnectionStatusAsync()
|
|||||||
|
|
||||||
Wallet::ConnectionStatus Wallet::connected(bool forceCheck)
|
Wallet::ConnectionStatus Wallet::connected(bool forceCheck)
|
||||||
{
|
{
|
||||||
|
if (!m_initialized)
|
||||||
|
{
|
||||||
|
return ConnectionStatus_Connecting;
|
||||||
|
}
|
||||||
|
|
||||||
// cache connection status
|
// cache connection status
|
||||||
if (forceCheck || !m_initialized || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) {
|
if (forceCheck || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) {
|
||||||
qDebug() << "Checking connection status";
|
qDebug() << "Checking connection status";
|
||||||
m_connectionStatusRunning = true;
|
m_connectionStatusRunning = true;
|
||||||
m_connectionStatusTime.restart();
|
m_connectionStatusTime.restart();
|
||||||
@ -277,14 +279,25 @@ void Wallet::initAsync(
|
|||||||
{
|
{
|
||||||
qDebug() << "initAsync: " + daemonAddress;
|
qDebug() << "initAsync: " + daemonAddress;
|
||||||
const auto future = m_scheduler.run([this, daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight, proxyAddress] {
|
const auto future = m_scheduler.run([this, daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight, proxyAddress] {
|
||||||
bool success = init(daemonAddress, trustedDaemon, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight, proxyAddress);
|
m_initialized = init(
|
||||||
if (success)
|
daemonAddress,
|
||||||
|
trustedDaemon,
|
||||||
|
upperTransactionLimit,
|
||||||
|
isRecovering,
|
||||||
|
isRecoveringFromDevice,
|
||||||
|
restoreHeight,
|
||||||
|
proxyAddress);
|
||||||
|
if (m_initialized)
|
||||||
{
|
{
|
||||||
emit walletCreationHeightChanged();
|
emit walletCreationHeightChanged();
|
||||||
qDebug() << "init async finished - starting refresh";
|
qDebug() << "init async finished - starting refresh";
|
||||||
connected(true);
|
connected(true);
|
||||||
startRefresh();
|
startRefresh();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qCritical() << "Failed to initialize the wallet";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (future.first)
|
if (future.first)
|
||||||
{
|
{
|
||||||
@ -1054,6 +1067,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
|||||||
, m_connectionStatus(Wallet::ConnectionStatus_Disconnected)
|
, m_connectionStatus(Wallet::ConnectionStatus_Disconnected)
|
||||||
, m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS)
|
, m_connectionStatusTtl(WALLET_CONNECTION_STATUS_CACHE_TTL_SECONDS)
|
||||||
, m_disconnected(true)
|
, m_disconnected(true)
|
||||||
|
, m_initialized(false)
|
||||||
, m_currentSubaddressAccount(0)
|
, m_currentSubaddressAccount(0)
|
||||||
, m_subaddress(nullptr)
|
, m_subaddress(nullptr)
|
||||||
, m_subaddressModel(nullptr)
|
, m_subaddressModel(nullptr)
|
||||||
@ -1074,7 +1088,6 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
|||||||
m_connectionStatusTime.start();
|
m_connectionStatusTime.start();
|
||||||
m_daemonBlockChainHeightTime.start();
|
m_daemonBlockChainHeightTime.start();
|
||||||
m_daemonBlockChainTargetHeightTime.start();
|
m_daemonBlockChainTargetHeightTime.start();
|
||||||
m_initialized = false;
|
|
||||||
m_connectionStatusRunning = false;
|
m_connectionStatusRunning = false;
|
||||||
m_daemonUsername = "";
|
m_daemonUsername = "";
|
||||||
m_daemonPassword = "";
|
m_daemonPassword = "";
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#ifndef WALLET_H
|
#ifndef WALLET_H
|
||||||
#define WALLET_H
|
#define WALLET_H
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
@ -444,7 +446,7 @@ private:
|
|||||||
int m_connectionStatusTtl;
|
int m_connectionStatusTtl;
|
||||||
mutable QElapsedTimer m_connectionStatusTime;
|
mutable QElapsedTimer m_connectionStatusTime;
|
||||||
bool m_disconnected;
|
bool m_disconnected;
|
||||||
mutable bool m_initialized;
|
std::atomic<bool> m_initialized;
|
||||||
uint32_t m_currentSubaddressAccount;
|
uint32_t m_currentSubaddressAccount;
|
||||||
Subaddress * m_subaddress;
|
Subaddress * m_subaddress;
|
||||||
mutable SubaddressModel * m_subaddressModel;
|
mutable SubaddressModel * m_subaddressModel;
|
||||||
|
Loading…
Reference in New Issue
Block a user