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
This commit is contained in:
Colin LeMahieu 2024-03-20 11:26:35 +00:00
commit c5b24e8000
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
6 changed files with 45 additions and 27 deletions

View file

@ -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

View file

@ -3,6 +3,7 @@
#include <nano/lib/numbers.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/election_insertion_result.hpp>
#include <nano/node/election_status.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/node/voting.hpp>
#include <nano/secure/common.hpp>

View file

@ -2,10 +2,10 @@
#include <nano/lib/id_dispenser.hpp>
#include <nano/lib/logging.hpp>
#include <nano/lib/stats_enums.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/election_status.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/secure/common.hpp>
#include <nano/store/component.hpp>
#include <atomic>
#include <chrono>
@ -13,6 +13,7 @@
namespace nano
{
class block;
class channel;
class confirmation_solicitor;
class inactive_cache_information;

View file

@ -0,0 +1,39 @@
#pragma once
#include <nano/lib/numbers.hpp>
#include <chrono>
#include <memory>
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<nano::block> winner;
nano::amount tally{ 0 };
nano::amount final_tally{ 0 };
std::chrono::milliseconds election_end{ std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()) };
std::chrono::milliseconds election_duration{ std::chrono::duration_values<std::chrono::milliseconds>::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 };
};
}

View file

@ -7,6 +7,7 @@
namespace nano
{
class election_status;
class telemetry;
class node_observers final
{

View file

@ -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<nano::block> winner;
nano::amount tally{ 0 };
nano::amount final_tally{ 0 };
std::chrono::milliseconds election_end{ std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()) };
std::chrono::milliseconds election_duration{ std::chrono::duration_values<std::chrono::milliseconds>::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 ();
}