diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index fb3be17c..bb6bbcc2 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -116,7 +116,9 @@ namespace epee void on_after_connect() { + LOG_PRINT_L2("SSL Handshake...."); m_socket.handshake(boost::asio::ssl::stream_base::client); + LOG_PRINT_L2("SSL Handshake OK"); } private: @@ -149,11 +151,52 @@ namespace epee { } + + void reset() + { + + } private: boost::asio::ip::tcp::socket m_socket; }; + template + struct socket_backend_resetable + { + socket_backend_resetable(boost::asio::io_service& _io_service) : mr_io_service(_io_service), m_pbackend(std::make_shared>(_io_service)) + {} + + boost::asio::ip::tcp::socket& get_socket() + { + return m_pbackend->get_socket(); + } + + void set_domain(const std::string& domain_name) + { + return m_pbackend->set_domain(domain_name); + } + + auto& get_stream() + { + return m_pbackend->get_stream(); + } + + void on_after_connect() + { + return m_pbackend->on_after_connect(); + } + + void reset() + { + m_pbackend = std::make_shared>(mr_io_service); + } + + private: + boost::asio::io_service& mr_io_service; + std::shared_ptr> m_pbackend; + }; + template @@ -227,6 +270,7 @@ namespace epee inline bool connect(const std::string& addr, const std::string& port, unsigned int connect_timeout, unsigned int reciev_timeout, const std::string& bind_ip = "0.0.0.0") { + LOG_PRINT_L1("Connecting to " << addr << ":" << port << ", cn_timeout: " << connect_timeout << ", rv_timeout: " << reciev_timeout); m_connect_timeout = connect_timeout; m_reciev_timeout = reciev_timeout; m_connected = false; @@ -238,7 +282,7 @@ namespace epee m_sct_back.get_socket().close(); // Get a list of endpoints corresponding to the server name. - + m_sct_back.reset(); ////////////////////////////////////////////////////////////////////////// boost::asio::ip::tcp::resolver resolver(m_io_service); @@ -281,13 +325,14 @@ namespace epee if (!ec && m_sct_back.get_socket().is_open()) { m_sct_back.on_after_connect(); - m_connected = true; + m_connected = true; m_deadline.expires_at(boost::posix_time::pos_infin); + LOG_PRINT_L1("Connected OK: " << addr << ":" << port); return true; } else { - LOG_PRINT("Some problems at connect, message: " << ec.message(), LOG_LEVEL_3); + LOG_PRINT("Error on connect to " << addr << ":" << port << ", message: " << ec.message(), LOG_LEVEL_3); return false; } @@ -652,7 +697,7 @@ namespace epee // The deadline has passed. The socket is closed so that any outstanding // asynchronous operations are cancelled. This allows the blocked // connect(), read_line() or write_line() functions to return. - LOG_PRINT_L3("Timed out socket"); + LOG_PRINT_L2("Timed out socket"); m_connected = false; m_sct_back.get_socket().close(); @@ -669,7 +714,7 @@ namespace epee protected: boost::asio::io_service m_io_service; - socket_backend m_sct_back; + socket_backend_resetable m_sct_back;//socket_backend m_sct_back; int m_connect_timeout; int m_reciev_timeout; bool m_initialized; diff --git a/src/wallet/core_default_rpc_proxy.h b/src/wallet/core_default_rpc_proxy.h index b693fca6..d82ec28d 100644 --- a/src/wallet/core_default_rpc_proxy.h +++ b/src/wallet/core_default_rpc_proxy.h @@ -87,13 +87,9 @@ namespace tools inline bool invoke_http_json_rpc_update_is_disconnect(const std::string& method_name, const t_request& req, t_response& res) { return call_request([&](){ -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_JSON_METHOD] ---> " << method_name) -#endif + LOG_PRINT_L2("[INVOKE_JSON_METHOD] ---> " << method_name) bool r = epee::net_utils::invoke_http_json_rpc("/json_rpc", method_name, req, res, m_http_client); -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_JSON_METHOD] <---" << method_name) -#endif + LOG_PRINT_L2("[INVOKE_JSON_METHOD] <---" << method_name) return r; }); } @@ -102,13 +98,9 @@ namespace tools inline bool invoke_http_bin_remote_command2_update_is_disconnect(const std::string& url, const t_request& req, t_response& res) { return call_request([&](){ -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_BIN] --->" << typeid(t_request).name()) -#endif + LOG_PRINT_L2("[INVOKE_BIN] --->" << typeid(t_request).name()) bool r = epee::net_utils::invoke_http_bin_remote_command2(m_daemon_address + url, req, res, m_http_client, m_connection_timeout); -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_BIN] <---" << typeid(t_request).name()) -#endif + LOG_PRINT_L2("[INVOKE_BIN] <---" << typeid(t_request).name()) return r; }); } @@ -117,13 +109,9 @@ namespace tools inline bool invoke_http_json_remote_command2_update_is_disconnect(const std::string& url, const t_request& req, t_response& res) { return call_request([&](){ -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_JSON_URL] --->" << typeid(t_request).name() ) -#endif + LOG_PRINT_L2("[INVOKE_JSON_URL] --->" << typeid(t_request).name() ) bool r = epee::net_utils::invoke_http_json_remote_command2(m_daemon_address + url, req, res, m_http_client, m_connection_timeout); -#ifdef MOBILE_WALLET_BUILD - LOG_PRINT_L0("[INVOKE_JSON_URL] <---" << typeid(t_request).name()) -#endif + LOG_PRINT_L2("[INVOKE_JSON_URL] <---" << typeid(t_request).name()) return r; }); } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index a25c97ab..62c2e947 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -603,8 +603,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t { if (pglobal_indexes->size()) { - //@#@ - WLT_LOG_L2("add_to_last_zc_global_indexs: h: " << height << ", b: " << currency::get_block_hash(b) << " , tx: " << currency::get_transaction_hash(tx) << ", last_zc_output_index: " << pglobal_indexes->back()); + WLT_LOG_L3("add_to_last_zc_global_indexs: h: " << height << ", b: " << currency::get_block_hash(b) << " , tx: " << currency::get_transaction_hash(tx) << ", last_zc_output_index: " << pglobal_indexes->back()); add_to_last_zc_global_indexs(ptc.height, pglobal_indexes->back()); } } diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index cf95e980..3c621038 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -33,26 +33,30 @@ DISABLE_VS_WARNINGS(4244) #include "jwt-cpp/jwt.h" POP_VS_WARNINGS + void test_plain_wallet() { //std::string res = plain_wallet::init("195.201.107.230", "33340", "C:\\Users\\roky\\home\\", 0); //std::string res = plain_wallet::init("", "", "C:\\Users\\roky\\home\\", 0); - std::string res = plain_wallet::init("http://zano.api.puffin.systems", "80", "C:\\Users\\roky\\home\\", 0); + std::string res = plain_wallet::init("https://node.zano.org", "443", "C:\\Users\\roky\\home\\", LOG_LEVEL_2); //std::string res = plain_wallet::init("127.0.0.1", "12111", "C:\\Users\\roky\\home22\\", 0); plain_wallet::configure_object conf = AUTO_VAL_INIT(conf); //plain_wallet::configure_response conf_resp = AUTO_VAL_INIT(conf_resp); conf.postponed_run_wallet = true; std::string r = plain_wallet::sync_call("configure", 0, epee::serialization::store_t_to_json(conf)); - + + std::string seed; + if (!epee::file_io_utils::load_file_to_string("C:\\Users\\roky\\home\\temp\\wallets\\seed.txt", seed)) + return; std::string res___ = plain_wallet::get_wallet_files(); uint64_t instance_id = 0; - res = plain_wallet::open("test_restored_2.zan", "111"); - //res = plain_wallet::restore("", - // "test_restored_2.zan", "111", ""); + res = plain_wallet::open("test_restored_3.zan", "111"); + //res = plain_wallet::restore(seed, + // "test_restored_3.zan", "111", "test"); epee::misc_utils::sleep_no_w(2000); @@ -67,7 +71,7 @@ void test_plain_wallet() res = plain_wallet::sync_call("get_wallet_status", instance_id, ""); view::wallet_sync_status_info wsi = AUTO_VAL_INIT(wsi); epee::serialization::load_t_from_json(wsi, res); - LOG_PRINT_L0("Progress: " << wsi.progress); + LOG_PRINT_L0("Progress: " << wsi.progress << " state: " << wsi.wallet_state << ", height: " << wsi.current_wallet_height << " of " << wsi.current_daemon_height); if (wsi.wallet_state == 2) break; } @@ -75,6 +79,8 @@ void test_plain_wallet() std::string invoke_body = "{\"method\":\"store\",\"params\":{}}"; std::string res1 = plain_wallet::sync_call("invoke", instance_id, invoke_body); + LOG_PRINT_L0("Store: " << res1); + return; { invoke_body = "{\"method\":\"getbalance\",\"params\":{}}"; std::string res3 = plain_wallet::sync_call("invoke", instance_id, invoke_body);