From 463228b9614d63afeb948fcb1ab3b27ece2c7347 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Thu, 28 Mar 2024 19:02:17 -0400 Subject: Skip privacy networks (on tx sends) that don't have outgoing connections --- src/cryptonote_protocol/levin_notify.cpp | 11 ++++++++--- src/cryptonote_protocol/levin_notify.h | 3 ++- src/p2p/net_node.inl | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cryptonote_protocol/levin_notify.cpp b/src/cryptonote_protocol/levin_notify.cpp index 5b420ec3f..1c3a2901c 100644 --- a/src/cryptonote_protocol/levin_notify.cpp +++ b/src/cryptonote_protocol/levin_notify.cpp @@ -741,9 +741,14 @@ namespace levin notify::status notify::get_status() const noexcept { if (!zone_) - return {false, false}; - - return {!zone_->noise.empty(), CRYPTONOTE_NOISE_CHANNELS <= zone_->connection_count}; + return {false, false, false}; + + // `connection_count` is only set when `!noise.empty()`. + const std::size_t connection_count = zone_->connection_count; + bool has_outgoing = connection_count; + if (zone_->noise.empty()) + has_outgoing = zone_->p2p->get_out_connections_count(); + return {!zone_->noise.empty(), CRYPTONOTE_NOISE_CHANNELS <= connection_count, has_outgoing}; } void notify::new_out_connection() diff --git a/src/cryptonote_protocol/levin_notify.h b/src/cryptonote_protocol/levin_notify.h index 52d36efb0..816170841 100644 --- a/src/cryptonote_protocol/levin_notify.h +++ b/src/cryptonote_protocol/levin_notify.h @@ -75,7 +75,8 @@ namespace levin struct status { bool has_noise; - bool connections_filled; + bool connections_filled; //!< True when has zone has `CRYPTONOTE_NOISE_CHANNELS` outgoing noise channels + bool has_outgoing; //!< True when zone has outgoing connections }; //! Construct an instance that cannot notify. diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 815c1b354..60f6728b3 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -2296,11 +2296,12 @@ namespace nodetool if (enet::zone::tor < network->first) break; // unknown network - if (network->second.m_connect) + const auto status = network->second.m_notifier.get_status(); + if (network->second.m_connect && status.has_outgoing) return send(*network); } - // configuration should not allow this scenario + MWARNING("Unable to send " << txs.size() << " transaction(s): anonymity networks had no outgoing connections"); return enet::zone::invalid; } //----------------------------------------------------------------------------------- -- cgit v1.2.3