From 387bafa78f7282da8ea99ea0fac058173af39064 Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Sun, 16 Nov 2025 08:19:40 +0000 Subject: [PATCH] jberman review --- .../cryptonote_protocol_handler.inl | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 7239d67bb7..0559daad60 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -63,7 +63,6 @@ #define MLOG_PEER_STATE(x) \ MCINFO(MONERO_DEFAULT_LOG_CATEGORY, context << "[" << epee::string_tools::to_string_hex(context.m_pruning_seed) << "] state: " << x << " in state " << cryptonote::get_protocol_state_string(context.m_state)) -#define BLOCK_QUEUE_NSPANS_THRESHOLD 200 // chunks of N blocks #define BLOCK_QUEUE_NSPANS_MINIMUM 10 // minimum number of spans #define BLOCK_QUEUE_SIZE_THRESHOLD (100*1024*1024) // MB #define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD_STANDBY (5 * 1000000) // microseconds @@ -1596,12 +1595,12 @@ namespace cryptonote m_block_queue.remove_spans(span_connection_id, start_height); const uint64_t current_blockchain_height = m_core.get_current_blockchain_height(); - const boost::posix_time::time_duration dt = boost::posix_time::microsec_clock::universal_time() - start; - const double blocks_per_seconds = (((current_blockchain_height - previous_height) * 1e6) / dt.total_microseconds()); - calculate_dynamic_span(blocks_per_seconds); if (current_blockchain_height > previous_height) { const uint64_t target_blockchain_height = m_core.get_target_blockchain_height(); + const boost::posix_time::time_duration dt = boost::posix_time::microsec_clock::universal_time() - start; + const double blocks_per_seconds = (((current_blockchain_height - previous_height) * 1e6) / dt.total_microseconds()); + calculate_dynamic_span(blocks_per_seconds); std::string progress_message = ""; if (current_blockchain_height < target_blockchain_height) { @@ -2043,11 +2042,7 @@ skip: const uint32_t peer_stripe = tools::get_pruning_stripe(context.m_pruning_seed); const uint32_t local_stripe = tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed()); const size_t block_queue_size_threshold = m_block_download_max_size ? m_block_download_max_size : BLOCK_QUEUE_SIZE_THRESHOLD; - size_t limit = m_span_limit.load(); - if (limit == 0) - limit = BLOCK_QUEUE_NSPANS_THRESHOLD; - m_span_limit.store(limit); - bool queue_proceed_init = (nspans < limit) && (size < block_queue_size_threshold); + bool queue_proceed_init = (nspans < m_span_limit.load()) && (size < block_queue_size_threshold); // get rid of blocks we already requested, or already have if (skip_unneeded_hashes(context, true) && context.m_needed_objects.empty() && context.m_num_requested == 0) { @@ -2178,7 +2173,7 @@ skip: NOTIFY_REQUEST_GET_OBJECTS::request req; bool is_next = false; size_t count = 0; - size_t l_m_bss = m_bss = m_core.get_block_sync_size(m_core.get_current_blockchain_height(), max_average_of_blocksize_in_queue()); + size_t l_m_bss = m_bss = m_core.get_block_sync_size(m_core.get_current_blockchain_height()); std::pair span = std::make_pair(0, 0); if (force_next_span) { @@ -2228,7 +2223,7 @@ skip: const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1; static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(8); bool sync_pruned_blocks = m_sync_pruned_blocks && first_block_height >= bp_fork_height && m_core.get_blockchain_pruning_seed(); - span = m_block_queue.reserve_span(first_block_height, context.m_last_response_height, count_limit, context.m_connection_id, context.m_remote_address, sync_pruned_blocks, m_core.get_blockchain_pruning_seed(), context.m_pruning_seed, context.m_remote_blockchain_height, context.m_needed_objects); + span = m_block_queue.reserve_span(first_block_height, context.m_last_response_height, l_m_bss, context.m_connection_id, context.m_remote_address, sync_pruned_blocks, m_core.get_blockchain_pruning_seed(), context.m_pruning_seed, context.m_remote_blockchain_height, context.m_needed_objects); MDEBUG(context << " span from " << first_block_height << ": " << span.first << "/" << span.second); if (span.second > 0) { @@ -2314,7 +2309,7 @@ skip: context.m_expect_height = span.first; context.m_expect_response = NOTIFY_RESPONSE_GET_OBJECTS::ID; MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_GET_OBJECTS: blocks.size()=" << req.blocks.size() - << "requested blocks count=" << count << " / " << count_limit << " from " << span.first << ", first hash " << req.blocks.front()); + << "requested blocks count=" << count << " / " << l_m_bss << " from " << span.first << ", first hash " << req.blocks.front()); //epee::net_utils::network_throttle_manager::get_global_throttle_inreq().logger_handle_net("log/dr-monero/net/req-all.data", sec, get_avg_block_size()); MDEBUG("Asking for " << (req.prune ? "pruned" : "full") << " data, start/end "