Remove inclusion of election.hpp from other headers

Moves election_behavior enum and vote_with_weight_info classes in to their own files.
Before:
[118/118] Linking CXX executable rpc_test
ninja  1208.77s user 85.03s system 875% cpu 2:27.78 total
After:
[39/39] Linking CXX executable rpc_test
ninja  338.18s user 25.74s system 714% cpu 50.953 total
This commit is contained in:
Colin LeMahieu 2024-03-20 11:10:19 +00:00
commit 0e441a9128
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
19 changed files with 60 additions and 32 deletions

View file

@ -1,6 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/confirmation_solicitor.hpp>
#include <nano/node/election.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/election.hpp>
#include <nano/node/request_aggregator.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/election.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_processor.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -1,6 +1,7 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/node/election.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/lmdb/wallet_value.hpp>
#include <nano/test_common/system.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/election.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/versioning.hpp>
#include <nano/test_common/system.hpp>

View file

@ -75,6 +75,7 @@ add_library(
distributed_work_factory.cpp
election.hpp
election.cpp
election_behavior.hpp
election_insertion_result.hpp
epoch_upgrader.hpp
epoch_upgrader.cpp
@ -164,6 +165,7 @@ add_library(
vote_cache.cpp
vote_processor.hpp
vote_processor.cpp
vote_with_weight_info.hpp
voting.hpp
voting.cpp
wallet.hpp

View file

@ -1,8 +1,9 @@
#pragma once
#include <nano/lib/numbers.hpp>
#include <nano/node/election.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/election_insertion_result.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/node/voting.hpp>
#include <nano/secure/common.hpp>

View file

@ -2,6 +2,8 @@
#include <nano/lib/id_dispenser.hpp>
#include <nano/lib/logging.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/secure/common.hpp>
#include <nano/store/component.hpp>
@ -24,34 +26,6 @@ public:
nano::block_hash hash;
};
class vote_with_weight_info final
{
public:
nano::account representative;
std::chrono::steady_clock::time_point time;
uint64_t timestamp;
nano::block_hash hash;
nano::uint128_t weight;
};
enum class election_behavior
{
normal,
/**
* Hinted elections:
* - shorter timespan
* - limited space inside AEC
*/
hinted,
/**
* Optimistic elections:
* - shorter timespan
* - limited space inside AEC
* - more frequent confirmation requests
*/
optimistic,
};
nano::stat::detail to_stat_detail (nano::election_behavior);
// map of vote weight per block, ordered greater first

View file

@ -0,0 +1,22 @@
#pragma once
namespace nano
{
enum class election_behavior
{
normal,
/**
* Hinted elections:
* - shorter timespan
* - limited space inside AEC
*/
hinted,
/**
* Optimistic elections:
* - shorter timespan
* - limited space inside AEC
* - more frequent confirmation requests
*/
optimistic,
};
}

View file

@ -16,7 +16,6 @@
#include <nano/node/bootstrap_ascending/service.hpp>
#include <nano/node/confirmation_height_processor.hpp>
#include <nano/node/distributed_work_factory.hpp>
#include <nano/node/election.hpp>
#include <nano/node/epoch_upgrader.hpp>
#include <nano/node/local_block_broadcaster.hpp>
#include <nano/node/network.hpp>

View file

@ -1,3 +1,4 @@
#include <nano/node/election.hpp>
#include <nano/node/node.hpp>
#include <nano/node/scheduler/manual.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/election.hpp>
#include <nano/node/node.hpp>
#include <nano/node/scheduler/buckets.hpp>
#include <nano/node/scheduler/priority.hpp>

View file

@ -1,4 +1,5 @@
#include <nano/lib/tomlconfig.hpp>
#include <nano/node/election.hpp>
#include <nano/node/node.hpp>
#include <nano/node/vote_cache.hpp>
@ -280,4 +281,4 @@ nano::error nano::vote_cache_config::deserialize (nano::tomlconfig & toml)
age_cutoff = std::chrono::seconds{ age_cutoff_l };
return toml.get_error ();
}
}

View file

@ -0,0 +1,18 @@
#pragma once
#include <nano/lib/numbers.hpp>
#include <chrono>
namespace nano
{
class vote_with_weight_info final
{
public:
nano::account representative;
std::chrono::steady_clock::time_point time;
uint64_t timestamp;
nano::block_hash hash;
nano::uint128_t weight;
};
}

View file

@ -3,7 +3,7 @@
#include <nano/lib/numbers.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/election.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/node/websocket_stream.hpp>
#include <nano/node/websocketconfig.hpp>
#include <nano/secure/common.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/qt/qt.hpp>
#include <nano/secure/ledger.hpp>

View file

@ -4,6 +4,7 @@
#include <nano/lib/rpcconfig.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/election.hpp>
#include <nano/node/ipc/ipc_server.hpp>
#include <nano/node/json_handler.hpp>
#include <nano/node/node_rpc_config.hpp>

View file

@ -1,5 +1,6 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp>
#include <nano/node/scheduler/priority.hpp>