Wallet API: Pause refresh while creating transaction

This commit is contained in:
Jacob Brydolf 2016-11-08 13:20:42 +01:00
parent 1372f255af
commit 0c530de057
No known key found for this signature in database
GPG Key ID: DE46246550D2F3C5

View File

@ -545,6 +545,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
{ {
clearStatus(); clearStatus();
// Pause refresh thread while creating transaction
pauseRefresh();
vector<cryptonote::tx_destination_entry> dsts; vector<cryptonote::tx_destination_entry> dsts;
cryptonote::tx_destination_entry de; cryptonote::tx_destination_entry de;
@ -678,6 +680,8 @@ PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const
transaction->m_status = m_status; transaction->m_status = m_status;
transaction->m_errorString = m_errorString; transaction->m_errorString = m_errorString;
// Resume refresh thread
startRefresh();
return transaction; return transaction;
} }
@ -798,6 +802,7 @@ void WalletImpl::doRefresh()
void WalletImpl::startRefresh() void WalletImpl::startRefresh()
{ {
LOG_PRINT_L2(__FUNCTION__ << ": refresh started/resumed...");
if (!m_refreshEnabled) { if (!m_refreshEnabled) {
m_refreshEnabled = true; m_refreshEnabled = true;
m_refreshCV.notify_one(); m_refreshCV.notify_one();
@ -818,6 +823,7 @@ void WalletImpl::stopRefresh()
void WalletImpl::pauseRefresh() void WalletImpl::pauseRefresh()
{ {
LOG_PRINT_L2(__FUNCTION__ << ": refresh paused...");
// TODO synchronize access // TODO synchronize access
if (!m_refreshThreadDone) { if (!m_refreshThreadDone) {
m_refreshEnabled = false; m_refreshEnabled = false;