mirror of
https://github.com/monero-project/monero.git
synced 2026-07-30 23:50:24 -07:00
wallet2_api: getter and setter for "refresh interval"
This commit is contained in:
@@ -428,6 +428,16 @@ void WalletImpl::refreshAsync()
|
||||
m_refreshCV.notify_one();
|
||||
}
|
||||
|
||||
void WalletImpl::setAutoRefreshInterval(int seconds)
|
||||
{
|
||||
m_refreshIntervalSeconds = seconds;
|
||||
}
|
||||
|
||||
int WalletImpl::autoRefreshInterval() const
|
||||
{
|
||||
return m_refreshIntervalSeconds;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// 1 - properly handle payment id (add another menthod with explicit 'payment_id' param)
|
||||
// 2 - check / design how "Transaction" can be single interface
|
||||
@@ -640,7 +650,15 @@ void WalletImpl::refreshThreadFunc()
|
||||
break;
|
||||
}
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": waiting for refresh...");
|
||||
m_refreshCV.wait(lock);
|
||||
// if auto refresh enabled, we wait for the "m_refreshIntervalSeconds" interval.
|
||||
// if not - we wait forever
|
||||
if (m_refreshIntervalSeconds > 0) {
|
||||
boost::posix_time::milliseconds wait_for_ms(m_refreshIntervalSeconds * 1000);
|
||||
m_refreshCV.timed_wait(lock, wait_for_ms);
|
||||
} else {
|
||||
m_refreshCV.wait(lock);
|
||||
}
|
||||
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << m_status);
|
||||
|
||||
@@ -77,6 +77,11 @@ public:
|
||||
uint64_t unlockedBalance() const;
|
||||
bool refresh();
|
||||
void refreshAsync();
|
||||
void setAutoRefreshInterval(int seconds);
|
||||
int autoRefreshInterval() const;
|
||||
|
||||
|
||||
|
||||
PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id,
|
||||
uint64_t amount, uint32_t mixin_count,
|
||||
PendingTransaction::Priority priority = PendingTransaction::Priority_Low);
|
||||
|
||||
@@ -223,10 +223,25 @@ struct Wallet
|
||||
* @return - true if refreshed successfully;
|
||||
*/
|
||||
virtual bool refresh() = 0;
|
||||
|
||||
/**
|
||||
* @brief refreshAsync - refreshes wallet asynchronously.
|
||||
*/
|
||||
virtual void refreshAsync() = 0;
|
||||
|
||||
/**
|
||||
* @brief setAutoRefreshInterval - setup interval for automatic refresh.
|
||||
* @param seconds - interval in seconds. if zero or less than zero - automatic refresh disabled;
|
||||
*/
|
||||
virtual void setAutoRefreshInterval(int seconds) = 0;
|
||||
|
||||
/**
|
||||
* @brief autoRefreshInterval - returns automatic refresh interval in seconds
|
||||
* @return
|
||||
*/
|
||||
virtual int autoRefreshInterval() const = 0;
|
||||
|
||||
|
||||
/*!
|
||||
* \brief createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored
|
||||
* \param dst_addr destination address as string
|
||||
|
||||
Reference in New Issue
Block a user