From b7b0395a03e1c1a8ff51b842e5ab9e975c0c569a Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:13:54 +0200 Subject: [PATCH] Simplified vote_generator logic --- nano/node/vote_generator.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/nano/node/vote_generator.cpp b/nano/node/vote_generator.cpp index 6f2e996a..00dccfd5 100644 --- a/nano/node/vote_generator.cpp +++ b/nano/node/vote_generator.cpp @@ -289,25 +289,19 @@ void nano::vote_generator::run () nano::unique_lock lock{ mutex }; while (!stopped) { - if (candidates.size () >= nano::network::confirm_ack_hashes_max) + condition.wait_for (lock, config.vote_generator_delay, [this] () { return this->candidates.size () >= nano::network::confirm_ack_hashes_max || !requests.empty (); }); + + if (!candidates.empty ()) { broadcast (lock); } + if (!requests.empty ()) { auto request (requests.front ()); requests.pop_front (); reply (lock, std::move (request)); } - else - { - condition.wait_for (lock, config.vote_generator_delay, [this] () { return this->candidates.size () >= nano::network::confirm_ack_hashes_max; }); - - if (!candidates.empty ()) - { - broadcast (lock); - } - } } }