Skip to content

Commit

Permalink
Fix activate immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jan 7, 2025
1 parent 9167393 commit a288a3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ enum class detail
transition_priority,
transition_priority_failed,
election_cleanup,
activate_immediately,

// active_elections
started,
Expand Down
13 changes: 9 additions & 4 deletions nano/node/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,16 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr<
count_by_behavior[result.election->behavior ()]++;

// Skip passive phase for blocks without cached votes to avoid bootstrap delays
bool active_immediately = false;
if (node.vote_cache.contains (hash))
bool activate_immediately = false;
if (!node.vote_cache.contains (hash))
{
activate_immediately = true;
}

if (activate_immediately)
{
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::activate_immediately);
result.election->transition_active ();
active_immediately = true;
}

node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::started);
Expand All @@ -436,7 +441,7 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr<
node.logger.debug (nano::log::type::active_elections, "Started new election for block: {} (behavior: {}, active immediately: {})",
hash.to_string (),
to_string (election_behavior_a),
active_immediately);
activate_immediately);
}
else
{
Expand Down

0 comments on commit a288a3a

Please sign in to comment.