From dc61500a462d99b60baf0e6d0d8da89ca933e2b0 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 10 Apr 2022 19:46:43 +0200 Subject: [PATCH] fixed http state machine, fixed wallet bug with tor connectivity failure --- contrib/epee/include/net/http_client.h | 2 +- contrib/tor-connect | 2 +- src/wallet/wallet2.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/epee/include/net/http_client.h b/contrib/epee/include/net/http_client.h index be81ba41..c0b57596 100644 --- a/contrib/epee/include/net/http_client.h +++ b/contrib/epee/include/net/http_client.h @@ -831,7 +831,7 @@ using namespace std; return false; }else { //Apparently there are no signs of the form of transfer, will receive data until the connection is closed - m_state = reciev_machine_state_error; + m_state = reciev_machine_state_body_connection_close; LOG_PRINT("Undefinded transfer type, consider http_body_transfer_connection_close method. header: " << m_header_cache, LOG_LEVEL_2); return false; } diff --git a/contrib/tor-connect b/contrib/tor-connect index 93d717ae..19c9c5d7 160000 --- a/contrib/tor-connect +++ b/contrib/tor-connect @@ -1 +1 @@ -Subproject commit 93d717aebc9ef56e1a9eaefc9d137574bda0038c +Subproject commit 19c9c5d79d40b7bde08598cf994ca0599803f489 diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 272cfcb6..9f4abdc6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4612,6 +4612,7 @@ void wallet2::send_transaction_to_network(const transaction& tx) //make few attempts tools::levin_over_tor_client p2p_client; p2p_client.get_transport().set_notifier(this); + bool succeseful_sent = false; for (size_t i = 0; i != 3; i++) { if (!p2p_client.connect("144.76.183.143", 2121, 10000)) @@ -4629,12 +4630,18 @@ void wallet2::send_transaction_to_network(const transaction& tx) if (p2p_rsp.code == API_RETURN_CODE_OK) { this->notify_state_change(WALLET_LIB_SENT_SUCCESS); + succeseful_sent = true; break; } this->notify_state_change(WALLET_LIB_SEND_FAILED); //checking if transaction got relayed to other nodes and //return; } + if (!succeseful_sent) + { + this->notify_state_change(WALLET_LIB_SEND_FAILED); + THROW_IF_FALSE_WALLET_EX(succeseful_sent, error::no_connection_to_daemon, "Faile to build TOR stream"); + } } else {