From bcf8ac0464b693e1d51c02b02defb00edef8442b Mon Sep 17 00:00:00 2001 From: gr0vity Date: Tue, 3 Dec 2024 15:53:13 +0100 Subject: [PATCH] simplify election_status initialization Replace inline initializations with the new constructor syntax while maintaining the same behavior. --- nano/node/election.cpp | 2 +- nano/node/election_status.hpp | 9 +++++++++ nano/node/json_handler.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nano/node/election.cpp b/nano/node/election.cpp index c42b55b771..125c4675fb 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -27,7 +27,7 @@ nano::election::election (nano::node & node_a, std::shared_ptr 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::system_clock::now ().time_since_epoch ()), std::chrono::duration_values::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 ()) diff --git a/nano/node/election_status.hpp b/nano/node/election_status.hpp index a69a490982..d75b7e3a99 100644 --- a/nano/node/election_status.hpp +++ b/nano/node/election_status.hpp @@ -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 block_a, election_status_type type_a = nano::election_status_type::ongoing) : + winner (block_a), + type (type_a) + { + block_count = 1; + } }; } diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 735da1e0a4..708e0e3f98 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -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::system_clock::now ().time_since_epoch ()), std::chrono::duration_values::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 ();