m_coinsModel = new CoinsModel(this, m_coins);
if (this->status() == Status_Ok) {
- startRefreshThread();
+ // startRefreshThread(); // Moved to startRefresh()
// Store the wallet every 2 minutes
m_storeTimer->start(2 * 60 * 1000);
// #################### Synchronization (Refresh) ####################
void Wallet::startRefresh() {
+ startRefreshThread();
m_refreshEnabled = true;
m_refreshNow = true;
}
void Wallet::startRefreshThread()
{
+ bool expected = false;
+ if (!m_refreshThreadStarted.compare_exchange_strong(expected, true)) {
+ return;
+ }
+
const auto future = m_scheduler.run([this] {
// Beware! This code does not run in the GUI thread.
std::atomic<bool> m_rangeSyncActive{false};
std::atomic<bool> m_syncPaused{false};
std::atomic<int64_t> m_lastRefreshTime{0};
+ std::atomic<bool> m_refreshThreadStarted{false};
};
#endif // FEATHER_WALLET_H