diff options
author | Ilya Kitaev <mbg033@gmail.com> | 2016-09-26 22:50:10 +0300 |
---|---|---|
committer | Ilya Kitaev <mbg033@gmail.com> | 2016-09-26 23:19:25 +0300 |
commit | 3079c5756be459af57c8c866b339b4b98c1da1f2 (patch) | |
tree | 12613206489610e43bf9504506bc6931aacd5638 /src | |
parent | wallet2_api: added Wallet::daemonBlockChainHeight() (diff) | |
download | monero-3079c5756be459af57c8c866b339b4b98c1da1f2.tar.xz |
wallet2_api: milliseconds resolution for auto-refresh interval
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/api/wallet.cpp | 16 | ||||
-rw-r--r-- | src/wallet/api/wallet.h | 4 | ||||
-rw-r--r-- | src/wallet/wallet2_api.h | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 986deca1f..9a001abf3 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -46,7 +46,7 @@ namespace Bitmonero { namespace { // copy-pasted from simplewallet static const size_t DEFAULT_MIXIN = 4; - static const int DEFAULT_REFRESH_INTERVAL_SECONDS = 10; + static const int DEFAULT_REFRESH_INTERVAL_MILLIS = 1000 * 10; } struct Wallet2CallbackImpl : public tools::i_wallet2_callback @@ -79,7 +79,7 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback if (m_listener) { m_listener->newBlock(height); - m_listener->updated(); + // m_listener->updated(); } } @@ -174,7 +174,7 @@ WalletImpl::WalletImpl(bool testnet) m_refreshThreadDone = false; m_refreshEnabled = false; - m_refreshIntervalSeconds = DEFAULT_REFRESH_INTERVAL_SECONDS; + m_refreshIntervalMillis = DEFAULT_REFRESH_INTERVAL_MILLIS; m_refreshThread = boost::thread([this] () { this->refreshThreadFunc(); @@ -451,14 +451,14 @@ void WalletImpl::refreshAsync() m_refreshCV.notify_one(); } -void WalletImpl::setAutoRefreshInterval(int seconds) +void WalletImpl::setAutoRefreshInterval(int millis) { - m_refreshIntervalSeconds = seconds; + m_refreshIntervalMillis = millis; } int WalletImpl::autoRefreshInterval() const { - return m_refreshIntervalSeconds; + return m_refreshIntervalMillis; } // TODO: @@ -675,8 +675,8 @@ void WalletImpl::refreshThreadFunc() LOG_PRINT_L3(__FUNCTION__ << ": waiting for refresh..."); // 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); + if (m_refreshIntervalMillis > 0) { + boost::posix_time::milliseconds wait_for_ms(m_refreshIntervalMillis); m_refreshCV.timed_wait(lock, wait_for_ms); } else { m_refreshCV.wait(lock); diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 03801edac..d97a8f3b3 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -79,7 +79,7 @@ public: uint64_t daemonBlockChainHeight() const; bool refresh(); void refreshAsync(); - void setAutoRefreshInterval(int seconds); + void setAutoRefreshInterval(int millis); int autoRefreshInterval() const; @@ -118,7 +118,7 @@ private: // multi-threaded refresh stuff std::atomic<bool> m_refreshEnabled; std::atomic<bool> m_refreshThreadDone; - std::atomic<int> m_refreshIntervalSeconds; + std::atomic<int> m_refreshIntervalMillis; // synchronizing refresh loop; boost::mutex m_refreshMutex; diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h index f424f7258..08e2ae16b 100644 --- a/src/wallet/wallet2_api.h +++ b/src/wallet/wallet2_api.h @@ -269,12 +269,12 @@ struct Wallet /** * @brief setAutoRefreshInterval - setup interval for automatic refresh. - * @param seconds - interval in seconds. if zero or less than zero - automatic refresh disabled; + * @param seconds - interval in millis. if zero or less than zero - automatic refresh disabled; */ - virtual void setAutoRefreshInterval(int seconds) = 0; + virtual void setAutoRefreshInterval(int millis) = 0; /** - * @brief autoRefreshInterval - returns automatic refresh interval in seconds + * @brief autoRefreshInterval - returns automatic refresh interval in millis * @return */ virtual int autoRefreshInterval() const = 0; |