diff options
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet2.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 39380c9df..094346293 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1232,19 +1232,22 @@ namespace tools template<class t_request, class t_response> inline bool invoke_http_json(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET") { - boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method); } template<class t_request, class t_response> inline bool invoke_http_bin(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET") { - boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method); } template<class t_request, class t_response> inline bool invoke_http_json_rpc(const boost::string_ref uri, const std::string& method_name, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0") { - boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, m_http_client, timeout, http_method, req_id); } @@ -1291,6 +1294,7 @@ namespace tools uint64_t hash_m_transfers(int64_t transfer_height, crypto::hash &hash) const; void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash); void enable_dns(bool enable) { m_use_dns = enable; } + void set_offline(bool offline = true); private: /*! @@ -1422,7 +1426,7 @@ namespace tools std::atomic<bool> m_run; - boost::mutex m_daemon_rpc_mutex; + boost::recursive_mutex m_daemon_rpc_mutex; bool m_trusted_daemon; i_wallet2_callback* m_callback; @@ -1474,6 +1478,7 @@ namespace tools std::string m_device_derivation_path; uint64_t m_device_last_key_image_sync; bool m_use_dns; + bool m_offline; // Aux transaction data from device std::unordered_map<crypto::hash, std::string> m_tx_device; |