Skip to content

Commit

Permalink
simplify election_status initialization
Browse files Browse the repository at this point in the history
Replace inline initializations with the new constructor syntax while maintaining the same behavior.
  • Loading branch information
gr0vity committed Dec 3, 2024
1 parent 0f1960d commit bcf8ac0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ nano::election::election (nano::node & node_a, std::shared_ptr<nano::block> cons
live_vote_action (live_vote_action_a),
node (node_a),
behavior_m (election_behavior_a),
status ({ block_a, 0, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 0, 1, 0, nano::election_status_type::ongoing }),
status (block_a),
height (block_a->sideband ().height),
root (block_a->root ()),
qualified_root (block_a->qualified_root ())
Expand Down
9 changes: 9 additions & 0 deletions nano/node/election_status.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,14 @@ class election_status final
unsigned block_count{ 0 };
unsigned voter_count{ 0 };
election_status_type type{ nano::election_status_type::inactive_confirmation_height };

election_status () = default;

election_status (std::shared_ptr<nano::block> block_a, election_status_type type_a = nano::election_status_type::ongoing) :
winner (block_a),
type (type_a)
{
block_count = 1;
}
};
}
2 changes: 1 addition & 1 deletion nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ void nano::json_handler::block_confirm ()
else
{
// Add record in confirmation history for confirmed block
nano::election_status status{ block_l, 0, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 0, 1, 0, nano::election_status_type::active_confirmation_height };
nano::election_status status{ block_l, nano::election_status_type::active_confirmation_height };
node.active.recently_cemented.put (status);
// Trigger callback for confirmed block
auto account = block_l->account ();
Expand Down

0 comments on commit bcf8ac0

Please sign in to comment.