From 6d28a3ea291cd6efdde50a2741f7e74473fa1374 Mon Sep 17 00:00:00 2001 From: gr0vity-dev Date: Sat, 30 Nov 2024 09:56:53 +0100 Subject: [PATCH] transition active for non live traffic --- nano/node/active_elections.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nano/node/active_elections.cpp b/nano/node/active_elections.cpp index bd29634bb2..6a8e86d325 100644 --- a/nano/node/active_elections.cpp +++ b/nano/node/active_elections.cpp @@ -396,6 +396,7 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr< return result; } + auto active_state = false; auto const root = block_a->qualified_root (); auto const hash = block_a->hash (); auto const existing = roots.get ().find (root); @@ -416,6 +417,13 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr< debug_assert (count_by_behavior[result.election->behavior ()] >= 0); count_by_behavior[result.election->behavior ()]++; + // If block is not in vote cache, transition to active immediately + if (node.vote_cache.find (hash).empty ()) + { + result.election->transition_active (); + active_state = true; + } + node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::started); node.stats.inc (nano::stat::type::active_elections_started, to_stat_detail (election_behavior_a)); @@ -423,9 +431,10 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr< nano::log::arg{ "behavior", election_behavior_a }, nano::log::arg{ "election", result.election }); - node.logger.debug (nano::log::type::active_elections, "Started new election for block: {} (behavior: {})", + node.logger.debug (nano::log::type::active_elections, "Started new election for block: {} (behavior: {}, active: {})", hash.to_string (), - to_string (election_behavior_a)); + to_string (election_behavior_a), + active_state); } else {