refreshing wallet even if error happened
This commit is contained in:
parent
6d32a3d16b
commit
d7597c5961
2 changed files with 18 additions and 6 deletions
|
@ -643,7 +643,7 @@ void WalletImpl::refreshThreadFunc()
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
|
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
|
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << m_status);
|
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << m_status);
|
||||||
if (m_refreshEnabled && m_status == Status_Ok) {
|
if (m_refreshEnabled /*&& m_status == Status_Ok*/) {
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": refreshing...");
|
LOG_PRINT_L3(__FUNCTION__ << ": refreshing...");
|
||||||
doRefresh();
|
doRefresh();
|
||||||
}
|
}
|
||||||
|
@ -657,16 +657,16 @@ void WalletImpl::doRefresh()
|
||||||
std::lock_guard<std::mutex> guarg(m_refreshMutex2);
|
std::lock_guard<std::mutex> guarg(m_refreshMutex2);
|
||||||
try {
|
try {
|
||||||
m_wallet->refresh();
|
m_wallet->refresh();
|
||||||
if (m_wallet2Callback->getListener()) {
|
|
||||||
m_wallet2Callback->getListener()->refreshed();
|
|
||||||
}
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
m_status = Status_Error;
|
m_status = Status_Error;
|
||||||
m_errorString = e.what();
|
m_errorString = e.what();
|
||||||
}
|
}
|
||||||
|
if (m_wallet2Callback->getListener()) {
|
||||||
|
m_wallet2Callback->getListener()->refreshed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// supposed to be called from ctor only
|
|
||||||
void WalletImpl::startRefresh()
|
void WalletImpl::startRefresh()
|
||||||
{
|
{
|
||||||
if (!m_refreshEnabled) {
|
if (!m_refreshEnabled) {
|
||||||
|
@ -676,7 +676,7 @@ void WalletImpl::startRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// supposed to be called from dtor only
|
|
||||||
void WalletImpl::stopRefresh()
|
void WalletImpl::stopRefresh()
|
||||||
{
|
{
|
||||||
if (!m_refreshThreadDone) {
|
if (!m_refreshThreadDone) {
|
||||||
|
@ -686,5 +686,13 @@ void WalletImpl::stopRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WalletImpl::pauseRefresh()
|
||||||
|
{
|
||||||
|
// TODO synchronize access
|
||||||
|
if (!m_refreshThreadDone) {
|
||||||
|
m_refreshEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -93,6 +93,7 @@ private:
|
||||||
void doRefresh();
|
void doRefresh();
|
||||||
void startRefresh();
|
void startRefresh();
|
||||||
void stopRefresh();
|
void stopRefresh();
|
||||||
|
void pauseRefresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class PendingTransactionImpl;
|
friend class PendingTransactionImpl;
|
||||||
|
@ -111,7 +112,10 @@ private:
|
||||||
std::atomic<bool> m_refreshEnabled;
|
std::atomic<bool> m_refreshEnabled;
|
||||||
std::atomic<bool> m_refreshThreadDone;
|
std::atomic<bool> m_refreshThreadDone;
|
||||||
std::atomic<int> m_refreshIntervalSeconds;
|
std::atomic<int> m_refreshIntervalSeconds;
|
||||||
|
// synchronizing refresh loop;
|
||||||
std::mutex m_refreshMutex;
|
std::mutex m_refreshMutex;
|
||||||
|
|
||||||
|
// synchronizing sync and async refresh
|
||||||
std::mutex m_refreshMutex2;
|
std::mutex m_refreshMutex2;
|
||||||
std::condition_variable m_refreshCV;
|
std::condition_variable m_refreshCV;
|
||||||
std::thread m_refreshThread;
|
std::thread m_refreshThread;
|
||||||
|
|
Loading…
Reference in a new issue