From c5b24e8000cb92da74d93f6fcea57397827b3fb8 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Wed, 20 Mar 2024 11:26:35 +0000 Subject: [PATCH] Reduce headers needed by election.hpp and moves election_status in to its own file Before: [39/39] Linking CXX executable rpc_test ninja 338.18s user 25.74s system 714% cpu 50.953 total After: [39/39] Linking CXX executable rpc_test ninja 339.33s user 27.66s system 778% cpu 47.155 total --- nano/node/CMakeLists.txt | 1 + nano/node/active_transactions.hpp | 1 + nano/node/election.hpp | 5 ++-- nano/node/election_status.hpp | 39 +++++++++++++++++++++++++++++++ nano/node/node_observers.hpp | 1 + nano/secure/common.hpp | 25 -------------------- 6 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 nano/node/election_status.hpp diff --git a/nano/node/CMakeLists.txt b/nano/node/CMakeLists.txt index 439ee94f..aee2e628 100644 --- a/nano/node/CMakeLists.txt +++ b/nano/node/CMakeLists.txt @@ -77,6 +77,7 @@ add_library( election.cpp election_behavior.hpp election_insertion_result.hpp + election_status.hpp epoch_upgrader.hpp epoch_upgrader.cpp ipc/action_handler.hpp diff --git a/nano/node/active_transactions.hpp b/nano/node/active_transactions.hpp index e1dececf..8d966dbb 100644 --- a/nano/node/active_transactions.hpp +++ b/nano/node/active_transactions.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/nano/node/election.hpp b/nano/node/election.hpp index 5ea0c43c..22dc8ab5 100644 --- a/nano/node/election.hpp +++ b/nano/node/election.hpp @@ -2,10 +2,10 @@ #include #include +#include #include +#include #include -#include -#include #include #include @@ -13,6 +13,7 @@ namespace nano { +class block; class channel; class confirmation_solicitor; class inactive_cache_information; diff --git a/nano/node/election_status.hpp b/nano/node/election_status.hpp new file mode 100644 index 00000000..014a14ad --- /dev/null +++ b/nano/node/election_status.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +#include +#include + +namespace nano +{ +class block; +} + +namespace nano +{ +/* Defines the possible states for an election to stop in */ +enum class election_status_type : uint8_t +{ + ongoing = 0, + active_confirmed_quorum = 1, + active_confirmation_height = 2, + inactive_confirmation_height = 3, + stopped = 5 +}; + +/* Holds a summary of an election */ +class election_status final +{ +public: + std::shared_ptr winner; + nano::amount tally{ 0 }; + nano::amount final_tally{ 0 }; + std::chrono::milliseconds election_end{ std::chrono::duration_cast (std::chrono::system_clock::now ().time_since_epoch ()) }; + std::chrono::milliseconds election_duration{ std::chrono::duration_values::zero () }; + unsigned confirmation_request_count{ 0 }; + unsigned block_count{ 0 }; + unsigned voter_count{ 0 }; + election_status_type type{ nano::election_status_type::inactive_confirmation_height }; +}; +} diff --git a/nano/node/node_observers.hpp b/nano/node/node_observers.hpp index 8825655c..083be5c3 100644 --- a/nano/node/node_observers.hpp +++ b/nano/node/node_observers.hpp @@ -7,6 +7,7 @@ namespace nano { +class election_status; class telemetry; class node_observers final { diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index d585e1b2..9ce8c55e 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -345,30 +345,5 @@ enum class confirmation_height_mode bounded }; -/* Defines the possible states for an election to stop in */ -enum class election_status_type : uint8_t -{ - ongoing = 0, - active_confirmed_quorum = 1, - active_confirmation_height = 2, - inactive_confirmation_height = 3, - stopped = 5 -}; - -/* Holds a summary of an election */ -class election_status final -{ -public: - std::shared_ptr winner; - nano::amount tally{ 0 }; - nano::amount final_tally{ 0 }; - std::chrono::milliseconds election_end{ std::chrono::duration_cast (std::chrono::system_clock::now ().time_since_epoch ()) }; - std::chrono::milliseconds election_duration{ std::chrono::duration_values::zero () }; - unsigned confirmation_request_count{ 0 }; - unsigned block_count{ 0 }; - unsigned voter_count{ 0 }; - election_status_type type{ nano::election_status_type::inactive_confirmation_height }; -}; - nano::wallet_id random_wallet_id (); }