From dff75a6fae3cc68c261cfb63e28f39ceb17656b4 Mon Sep 17 00:00:00 2001 From: ravinsp <33562092+ravinsp@users.noreply.github.com> Date: Sat, 3 Jun 2023 19:03:32 +0530 Subject: [PATCH] Added logging for known peer connection attempt reporting. --- src/p2p/peer_comm_server.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/p2p/peer_comm_server.cpp b/src/p2p/peer_comm_server.cpp index ac9e569c..cbfd0dc1 100644 --- a/src/p2p/peer_comm_server.cpp +++ b/src/p2p/peer_comm_server.cpp @@ -225,9 +225,15 @@ namespace p2p { const auto itr = std::find(failed_nodes.begin(), failed_nodes.end(), it->ip_port); if (itr != failed_nodes.end()) + { it->failed_attempts++; + LOG_DEBUG << "Failed attempts: " << it->failed_attempts << " for peer " << it->ip_port.to_string(); + } else if (it->failed_attempts > 0) // Reset failed attempts count if the connection succeeds. + { it->failed_attempts = 0; + LOG_DEBUG << "Failed attempts reset for peer " << it->ip_port.to_string(); + } if (it->failed_attempts >= PEER_FAILED_THRESHOLD) { @@ -237,13 +243,15 @@ namespace p2p it = req_known_remotes.erase(it); } else + { ++it; + } } } } /** * Check whether the node is weakly connected or strongly connected. - */ + */ void peer_comm_server::detect_if_weakly_connected() { // If the node is already weakly connected, check every 2 seconds whether we are now strongly connected.