diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp index c6ea14556..9a977d5c3 100644 --- a/contrib/epee/src/net_ssl.cpp +++ b/contrib/epee/src/net_ssl.cpp @@ -128,7 +128,7 @@ namespace net_utils // https://stackoverflow.com/questions/256405/programmatically-create-x509-certificate-using-openssl bool create_rsa_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert) { - MGINFO("Generating SSL certificate"); + MINFO("Generating SSL certificate"); pkey = EVP_PKEY_new(); if (!pkey) { @@ -198,7 +198,7 @@ bool create_rsa_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert) bool create_ec_ssl_certificate(EVP_PKEY *&pkey, X509 *&cert, int type) { - MGINFO("Generating SSL certificate"); + MINFO("Generating SSL certificate"); pkey = EVP_PKEY_new(); if (!pkey) { diff --git a/src/cryptonote_protocol/levin_notify.cpp b/src/cryptonote_protocol/levin_notify.cpp index 4b41b5bfc..bb2f0523b 100644 --- a/src/cryptonote_protocol/levin_notify.cpp +++ b/src/cryptonote_protocol/levin_notify.cpp @@ -43,6 +43,9 @@ #include "net/dandelionpp.h" #include "p2p/net_node.h" +#undef LOKI_DEFAULT_LOG_CATEGORY +#define LOKI_DEFAULT_LOG_CATEGORY "net.p2p.tx" + namespace cryptonote { namespace levin @@ -242,6 +245,8 @@ namespace levin if (!channel.connection.is_nil()) channel.queue.push_back(std::move(message_)); + else if (destination_ == 0 && zone_->connection_count == 0) + MWARNING("Unable to send transaction(s) over anonymity network - no available outbound connections"); } }; @@ -441,9 +446,12 @@ namespace levin { channel.active = nullptr; channel.connection = boost::uuids::nil_uuid(); - zone_->strand.post( - update_channels{zone_, get_out_connections(*zone_->p2p)} - ); + + auto connections = get_out_connections(*zone_->p2p); + if (connections.empty()) + MWARNING("Lost all outbound connections to anonymity network - currently unable to send transaction(s)"); + + zone_->strand.post(update_channels{zone_, std::move(connections)}); } } diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 59ac313f0..ea39bbd4d 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1048,17 +1048,15 @@ namespace nodetool pi = context.peer_id = rsp.node_data.peer_id; context.m_rpc_port = rsp.node_data.rpc_port; - m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port); + network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone()); + zone.m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port); // move - for (auto const& zone : m_network_zones) + if(rsp.node_data.peer_id == zone.m_config.m_peer_id) { - if(rsp.node_data.peer_id == zone.second.m_config.m_peer_id) - { - LOG_DEBUG_CC(context, "Connection to self detected, dropping connection"); - hsh_result = false; - return; - } + LOG_DEBUG_CC(context, "Connection to self detected, dropping connection"); + hsh_result = false; + return; } LOG_INFO_CC(context, "New connection handshaked, pruning seed " << epee::string_tools::to_string_hex(context.m_pruning_seed)); LOG_DEBUG_CC(context, " COMMAND_HANDSHAKE INVOKED OK"); diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp index e5ca4e41e..7790852bb 100644 --- a/tests/unit_tests/levin.cpp +++ b/tests/unit_tests/levin.cpp @@ -458,8 +458,8 @@ TEST_F(levin_notify, flood) } std::vector txs(2); - txs[0].resize(100, 'e'); - txs[1].resize(200, 'f'); + txs[0].resize(100, 'f'); + txs[1].resize(200, 'e'); ASSERT_EQ(10u, contexts_.size()); { @@ -472,6 +472,7 @@ TEST_F(levin_notify, flood) for (++context; context != contexts_.end(); ++context) EXPECT_EQ(1u, context->process_send_queue()); + std::sort(txs.begin(), txs.end()); ASSERT_EQ(9u, receiver_.notified_size()); for (unsigned count = 0; count < 9; ++count) { @@ -492,6 +493,7 @@ TEST_F(levin_notify, flood) for (++context; context != contexts_.end(); ++context) EXPECT_EQ(1u, context->process_send_queue()); + std::sort(txs.begin(), txs.end()); ASSERT_EQ(9u, receiver_.notified_size()); for (unsigned count = 0; count < 9; ++count) { @@ -523,8 +525,8 @@ TEST_F(levin_notify, private_flood) } std::vector txs(2); - txs[0].resize(100, 'e'); - txs[1].resize(200, 'f'); + txs[0].resize(100, 'f'); + txs[1].resize(200, 'e'); ASSERT_EQ(10u, contexts_.size()); {