aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/api/wallet.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/api/wallet.h')
-rw-r--r--src/wallet/api/wallet.h30
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;
+
};