Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libwalletqt: refresh once on wallet opening #3994

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/libwalletqt/Wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ bool Wallet::refresh(bool historyAndSubaddresses /* = true */)
void Wallet::startRefresh()
{
m_refreshEnabled = true;
m_refreshNow = true;
}

void Wallet::pauseRefresh()
Expand Down Expand Up @@ -1142,6 +1143,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
, m_subaddressModel(nullptr)
, m_subaddressAccount(new SubaddressAccount(m_walletImpl->subaddressAccount(), this))
, m_subaddressAccountModel(nullptr)
, m_refreshNow(false)
, m_refreshEnabled(false)
, m_refreshing(false)
, m_scheduler(this)
Expand Down Expand Up @@ -1195,10 +1197,11 @@ void Wallet::startRefreshThread()
{
const auto now = std::chrono::steady_clock::now();
const auto elapsed = now - last;
if (elapsed >= refreshInterval)
if (elapsed >= refreshInterval || m_refreshNow)
{
refresh(false);
last = std::chrono::steady_clock::now();
m_refreshNow = false;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/libwalletqt/Wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ class Wallet : public QObject, public PassprasePrompter
QString m_daemonPassword;
QString m_proxyAddress;
mutable QMutex m_proxyMutex;
std::atomic<bool> m_refreshNow;
std::atomic<bool> m_refreshEnabled;
std::atomic<bool> m_refreshing;
WalletListenerImpl *m_walletListener;
Expand Down