Skip to content

Commit

Permalink
Reprocess election winner blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 28, 2024
1 parent 6a4068c commit 52c1d23
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ enum class detail
unchecked,
local,
forced,
election,

// message specific
not_a_type,
Expand Down
2 changes: 1 addition & 1 deletion nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ nano::block_processor::block_processor (nano::node_config const & node_config, n
case nano::block_source::local:
return config.priority_local;
default:
return 1;
return config.priority_system;
}
};

Expand Down
2 changes: 2 additions & 0 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum class block_source
unchecked,
local,
forced,
election,
};

std::string_view to_string (block_source);
Expand All @@ -47,6 +48,7 @@ class block_processor_config final
size_t priority_live{ 1 };
size_t priority_bootstrap{ 8 };
size_t priority_local{ 16 };
size_t priority_system{ 32 };

size_t batch_size{ 256 };
size_t max_queued_notifications{ 8 };
Expand Down
4 changes: 3 additions & 1 deletion nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ void nano::election::confirm_if_quorum (nano::unique_lock<nano::mutex> & lock_a)
{
debug_assert (lock_a.owns_lock ());
auto tally_l (tally_impl ());
debug_assert (!tally_l.empty ());
release_assert (!tally_l.empty ());
auto winner (tally_l.begin ());
auto block_l (winner->second);
auto const & winner_hash_l (block_l->hash ());
Expand All @@ -425,6 +425,8 @@ void nano::election::confirm_if_quorum (nano::unique_lock<nano::mutex> & lock_a)
}
if (final_weight >= node.online_reps.delta ())
{
// In some edge cases block might get rolled back while the election is confirming, reprocess it to ensure it's present in the ledger
node.block_processor.add (block_l, nano::block_source::election);
confirm_once (lock_a);
debug_assert (!lock_a.owns_lock ());
}
Expand Down

0 comments on commit 52c1d23

Please sign in to comment.