diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-07-23 09:17:21 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-07-23 09:17:21 +0200 |
commit | b582764bd659372d99144a62be4ded45cc47be2d (patch) | |
tree | ad3ca78a09384e33cee7de4fe5159b0bbde2be6e /src/wallet/api/wallet.h | |
parent | Merge pull request #910 (diff) | |
parent | refreshing wallet even if error happened (diff) | |
download | monero-b582764bd659372d99144a62be4ded45cc47be2d.tar.xz |
Merge pull request #915
d7597c5 refreshing wallet even if error happened (Ilya Kitaev)
6d32a3d wallet_api: async init, Wallet::connected status, log level (Ilya Kitaev)
193d251 libwallet_api cmake: conditionally creating libwallet_merged2 only for STATIC build (Ilya Kitaev)
10c06dd wallet_api: segfault on refresh fixed (Ilya Kitaev)
9d2cb4f WalletListener functionality (Ilya Kitaev)
d27b883 hack to successfull linking for MSYS2 (Ilya Kitaev)
083380c Transaction fee multiplier aka priority integraged (Ilya Kitaev)
00ed12b Wallet::paymentIdValid (Ilya Kitaev)
Diffstat (limited to 'src/wallet/api/wallet.h')
-rw-r--r-- | src/wallet/api/wallet.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 164aede1a..9a290e0bc 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -35,6 +35,9 @@ #include "wallet/wallet2.h" #include <string> +#include <thread> +#include <mutex> +#include <condition_variable> namespace Bitmonero { @@ -65,14 +68,19 @@ public: std::string filename() const; std::string keysFilename() const; bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit); + void initAsync(const std::string &daemon_address, uint64_t upper_transaction_size_limit); bool connectToDaemon(); + bool connected() const; void setTrustedDaemon(bool arg); bool trustedDaemon() const; uint64_t balance() const; uint64_t unlockedBalance() const; bool refresh(); + void refreshAsync(); PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, - uint64_t amount, uint32_t mixin_count); + uint64_t amount, uint32_t mixin_count, + PendingTransaction::Priority priority = PendingTransaction::Priority_Low); + virtual void disposeTransaction(PendingTransaction * t); virtual TransactionHistory * history() const; virtual void setListener(WalletListener * l); @@ -81,19 +89,37 @@ public: private: void clearStatus(); + void refreshThreadFunc(); + void doRefresh(); + void startRefresh(); + void stopRefresh(); + void pauseRefresh(); private: friend class PendingTransactionImpl; friend class TransactionHistoryImpl; tools::wallet2 * m_wallet; - int m_status; + std::atomic<int> m_status; std::string m_errorString; std::string m_password; TransactionHistoryImpl * m_history; bool m_trustedDaemon; WalletListener * m_walletListener; Wallet2CallbackImpl * m_wallet2Callback; + + // multi-threaded refresh stuff + std::atomic<bool> m_refreshEnabled; + std::atomic<bool> m_refreshThreadDone; + std::atomic<int> m_refreshIntervalSeconds; + // synchronizing refresh loop; + std::mutex m_refreshMutex; + + // synchronizing sync and async refresh + std::mutex m_refreshMutex2; + std::condition_variable m_refreshCV; + std::thread m_refreshThread; + }; |