diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index 35ec15c6..afef7a68 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -399,7 +399,7 @@ void nano::active_transactions::request_confirm (nano::unique_lock & } this->condition.notify_all (); }, - 10); // 500ms / (10ms / 1 block) > 30 blocks + 10); // 10ms/block * 30blocks = 300ms < 500ms } // Batch confirmation request if (!batched_confirm_req_bundle_l.empty ()) @@ -412,7 +412,7 @@ void nano::active_transactions::request_confirm (nano::unique_lock & } this->condition.notify_all (); }, - 20); // 500ms / (20ms / 5 batch size) > (20*7 = 140) batches + 15); // 15ms/batch * 20batches = 300ms < 500ms } // Single confirmation requests if (!single_confirm_req_bundle_l.empty ()) @@ -425,7 +425,7 @@ void nano::active_transactions::request_confirm (nano::unique_lock & } this->condition.notify_all (); }, - 10); // 500ms / (10-20ms / 1 req) > 15 reqs + 30); // 30~60ms/req * 5 reqs = 150~300ms < 500ms } lock_a.lock (); // Erase inactive elections diff --git a/nano/node/active_transactions.hpp b/nano/node/active_transactions.hpp index 9f4a2f0e..f6fde3a3 100644 --- a/nano/node/active_transactions.hpp +++ b/nano/node/active_transactions.hpp @@ -135,7 +135,7 @@ public: static size_t constexpr max_block_broadcasts = 30; static size_t constexpr max_confirm_representatives = 30; static size_t constexpr max_confirm_req_batches = 20; - static size_t constexpr max_confirm_req = 15; + static size_t constexpr max_confirm_req = 5; boost::circular_buffer multipliers_cb; uint64_t trended_active_difficulty; size_t priority_cementable_frontiers_size (); diff --git a/nano/node/network.cpp b/nano/node/network.cpp index 50695a83..4f4f61ed 100644 --- a/nano/node/network.cpp +++ b/nano/node/network.cpp @@ -331,35 +331,30 @@ void nano::network::broadcast_confirm_req_base (std::shared_ptr blo void nano::network::broadcast_confirm_req_batched_many (std::unordered_map, std::deque>> request_bundle_a, std::function callback_a, unsigned delay_a, bool resumption_a) { - const size_t burst_size_l{ 5 }; if (!resumption_a && node.config.logging.network_logging ()) { node.logger.try_log (boost::str (boost::format ("Broadcasting batch confirm req to %1% representatives") % request_bundle_a.size ())); } - for (size_t count_l (0); !request_bundle_a.empty () && count_l < burst_size_l; ++count_l) + for (auto i (request_bundle_a.begin ()), n (request_bundle_a.end ()); i != n;) { - auto j (request_bundle_a.begin ()); - while (j != request_bundle_a.end ()) + std::vector> roots_hashes_l; + // Limit max request size hash + root to 7 pairs + while (roots_hashes_l.size () < confirm_req_hashes_max && !i->second.empty ()) { - std::vector> roots_hashes_l; - // Limit max request size hash + root to 7 pairs - while (roots_hashes_l.size () < confirm_req_hashes_max && !j->second.empty ()) - { - // expects ordering by priority, descending - roots_hashes_l.push_back (j->second.front ()); - j->second.pop_front (); - } - nano::confirm_req req (roots_hashes_l); - j->first->send (req); - if (j->second.empty ()) - { - j = request_bundle_a.erase (j); - } - else - { - ++j; - } + // expects ordering by priority, descending + roots_hashes_l.push_back (i->second.front ()); + i->second.pop_front (); + } + nano::confirm_req req (roots_hashes_l); + i->first->send (req); + if (i->second.empty ()) + { + i = request_bundle_a.erase (i); + } + else + { + ++i; } } if (!request_bundle_a.empty ())