@@ -233,7 +233,7 @@ namespace levin
233
233
{
234
234
struct zone
235
235
{
236
- explicit zone (boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in, bool is_public , bool pad_txs)
236
+ explicit zone (boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in, epee::net_utils::zone zone , bool pad_txs)
237
237
: p2p(std::move(p2p)),
238
238
noise(std::move(noise_in)),
239
239
next_epoch(io_service),
@@ -243,7 +243,7 @@ namespace levin
243
243
channels(),
244
244
connection_count(0 ),
245
245
flush_callbacks(0 ),
246
- is_public(is_public ),
246
+ nzone(zone ),
247
247
pad_txs(pad_txs),
248
248
fluffing(false )
249
249
{
@@ -260,7 +260,7 @@ namespace levin
260
260
std::deque<noise_channel> channels; // !< Never touch after init; only update elements on `noise_channel.strand`
261
261
std::atomic<std::size_t > connection_count; // !< Only update in strand, can be read at any time
262
262
std::uint32_t flush_callbacks; // !< Number of active fluff flush callbacks queued
263
- const bool is_public ; // !< Zone is public ipv4/ipv6 connections
263
+ const epee::net_utils::zone nzone ; // !< Zone is public ipv4/ipv6 connections, or i2p or tor
264
264
const bool pad_txs; // !< Pad txs to the next boundary for privacy
265
265
bool fluffing; // !< Zone is in Dandelion++ fluff epoch
266
266
};
@@ -297,7 +297,8 @@ namespace levin
297
297
if (!channel.connection .is_nil ())
298
298
channel.queue .push_back (std::move (message_));
299
299
else if (destination_ == 0 && zone_->connection_count == 0 )
300
- MWARNING (" Unable to send transaction(s) over anonymity network - no available outbound connections" );
300
+ MWARNING (" Unable to send transaction(s) to " << epee::net_utils::zone_to_string (zone_->nzone ) <<
301
+ " - no available outbound connections" );
301
302
}
302
303
};
303
304
@@ -399,7 +400,7 @@ namespace levin
399
400
zone->p2p ->foreach_connection ([txs, now, &zone, &source, &in_duration, &out_duration, &next_flush] (detail::p2p_context& context)
400
401
{
401
402
// When i2p/tor, only fluff to outbound connections
402
- if (source != context.m_connection_id && (zone->is_public || !context.m_is_income ))
403
+ if (source != context.m_connection_id && (zone->nzone == epee::net_utils::zone::public_ || !context.m_is_income ))
403
404
{
404
405
if (context.fluff_txs .empty ())
405
406
context.flush_time = now + (context.m_is_income ? in_duration () : out_duration ());
@@ -562,7 +563,7 @@ namespace levin
562
563
563
564
assert (zone_->strand .running_in_this_thread ());
564
565
565
- if (zone_->is_public )
566
+ if (zone_->nzone == epee::net_utils::zone::public_ )
566
567
MDEBUG (" Starting new Dandelion++ epoch: " << (fluffing_ ? " fluff" : " stem" ));
567
568
568
569
zone_->map = std::move (map_);
@@ -630,10 +631,12 @@ namespace levin
630
631
{
631
632
channel.active = nullptr ;
632
633
channel.connection = boost::uuids::nil_uuid ();
634
+ auto height = core_->get_target_blockchain_height ();
633
635
634
- auto connections = get_out_connections (*zone_->p2p , core_-> get_target_blockchain_height () );
636
+ auto connections = get_out_connections (*zone_->p2p , height );
635
637
if (connections.empty ())
636
- MWARNING (" Lost all outbound connections to anonymity network - currently unable to send transaction(s)" );
638
+ MWARNING (" Unable to send transaction(s) to " << epee::net_utils::zone_to_string (zone_->nzone ) <<
639
+ " - no suitable outbound connections at height " << height);
637
640
638
641
zone_->strand .post (update_channels{zone_, std::move (connections)});
639
642
}
@@ -676,15 +679,15 @@ namespace levin
676
679
};
677
680
} // anonymous
678
681
679
- notify::notify (boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, const bool is_public , const bool pad_txs, i_core_events& core)
680
- : zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise), is_public , pad_txs))
682
+ notify::notify (boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, epee::net_utils::zone zone , const bool pad_txs, i_core_events& core)
683
+ : zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise), zone , pad_txs))
681
684
, core_(std::addressof(core))
682
685
{
683
686
if (!zone_->p2p )
684
687
throw std::logic_error{" cryptonote::levin::notify cannot have nullptr p2p argument" };
685
688
686
689
const bool noise_enabled = !zone_->noise .empty ();
687
- if (noise_enabled || is_public )
690
+ if (noise_enabled || zone == epee::net_utils::zone::public_ )
688
691
{
689
692
const auto now = std::chrono::steady_clock::now ();
690
693
const auto min_epoch = noise_enabled ? noise_min_epoch : dandelionpp_min_epoch;
@@ -806,7 +809,7 @@ namespace levin
806
809
case relay_method::stem:
807
810
case relay_method::forward:
808
811
case relay_method::local:
809
- if (zone_->is_public )
812
+ if (zone_->nzone == epee::net_utils::zone::public_ )
810
813
{
811
814
// this will change a local/forward tx to stem or fluff ...
812
815
zone_->strand .dispatch (
0 commit comments