diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index d51b34268..252f6e07f 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -169,7 +170,7 @@ public: bool read_only{ false }; bool disable_connection_cleanup{ false }; nano::confirmation_height_mode confirmation_height_processor_mode{ nano::confirmation_height_mode::automatic }; - nano::generate_cache generate_cache; + nano::generate_cache_flags generate_cache; bool inactive_node{ false }; std::size_t block_processor_batch_size{ 0 }; std::size_t block_processor_full_size{ 65536 }; diff --git a/nano/secure/CMakeLists.txt b/nano/secure/CMakeLists.txt index f80ac9d8b..11f3f8c42 100644 --- a/nano/secure/CMakeLists.txt +++ b/nano/secure/CMakeLists.txt @@ -41,6 +41,8 @@ add_library( ${CMAKE_BINARY_DIR}/bootstrap_weights_beta.cpp common.hpp common.cpp + generate_cache_flags.hpp + generate_cache_flags.cpp ledger.hpp ledger.cpp network_filter.hpp diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index 6b91dd676..0a050c972 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -484,14 +484,6 @@ nano::block_hash const & nano::unchecked_key::key () const return previous; } -void nano::generate_cache::enable_all () -{ - reps = true; - cemented_count = true; - unchecked_count = true; - account_count = true; -} - std::string_view nano::to_string (nano::block_status code) { return magic_enum::enum_name (code); diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 9ce685825..c8dd6389e 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -405,20 +405,6 @@ enum class confirmation_height_mode bounded }; -/* Holds flags for various cacheable data. For most CLI operations caching is unnecessary - * (e.g getting the cemented block count) so it can be disabled for performance reasons. */ -class generate_cache -{ -public: - bool reps = true; - bool cemented_count = true; - bool unchecked_count = true; - bool account_count = true; - bool block_count = true; - - void enable_all (); -}; - /* Holds an in-memory cache of various counts */ class ledger_cache { diff --git a/nano/secure/generate_cache_flags.cpp b/nano/secure/generate_cache_flags.cpp new file mode 100644 index 000000000..912932cee --- /dev/null +++ b/nano/secure/generate_cache_flags.cpp @@ -0,0 +1,9 @@ +#include + +void nano::generate_cache_flags::enable_all () +{ + reps = true; + cemented_count = true; + unchecked_count = true; + account_count = true; +} diff --git a/nano/secure/generate_cache_flags.hpp b/nano/secure/generate_cache_flags.hpp new file mode 100644 index 000000000..29445e53d --- /dev/null +++ b/nano/secure/generate_cache_flags.hpp @@ -0,0 +1,18 @@ +#pragma once + +namespace nano +{ +/* Holds flags for various cacheable data. For most CLI operations caching is unnecessary + * (e.g getting the cemented block count) so it can be disabled for performance reasons. */ +class generate_cache_flags +{ +public: + bool reps = true; + bool cemented_count = true; + bool unchecked_count = true; + bool account_count = true; + bool block_count = true; + + void enable_all (); +}; +} diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 74b70e6e2..ca6ec8b2f 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -750,7 +750,7 @@ void representative_visitor::state_block (nano::state_block const & block_a) } } // namespace -nano::ledger::ledger (nano::store::component & store_a, nano::stats & stat_a, nano::ledger_constants & constants, nano::generate_cache const & generate_cache_a) : +nano::ledger::ledger (nano::store::component & store_a, nano::stats & stat_a, nano::ledger_constants & constants, nano::generate_cache_flags const & generate_cache_flags_a) : constants{ constants }, store{ store_a }, stats{ stat_a }, @@ -758,13 +758,13 @@ nano::ledger::ledger (nano::store::component & store_a, nano::stats & stat_a, na { if (!store.init_error ()) { - initialize (generate_cache_a); + initialize (generate_cache_flags_a); } } -void nano::ledger::initialize (nano::generate_cache const & generate_cache_a) +void nano::ledger::initialize (nano::generate_cache_flags const & generate_cache_flags_a) { - if (generate_cache_a.reps || generate_cache_a.account_count || generate_cache_a.block_count) + if (generate_cache_flags_a.reps || generate_cache_flags_a.account_count || generate_cache_flags_a.block_count) { store.account.for_each_par ( [this] (store::read_transaction const & /*unused*/, store::iterator i, store::iterator n) { @@ -784,7 +784,7 @@ void nano::ledger::initialize (nano::generate_cache const & generate_cache_a) }); } - if (generate_cache_a.cemented_count) + if (generate_cache_flags_a.cemented_count) { store.confirmation_height.for_each_par ( [this] (store::read_transaction const & /*unused*/, store::iterator i, store::iterator n) { diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index f2477222e..321adaec8 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -28,7 +29,7 @@ public: class ledger final { public: - ledger (nano::store::component &, nano::stats &, nano::ledger_constants & constants, nano::generate_cache const & = nano::generate_cache ()); + ledger (nano::store::component &, nano::stats &, nano::ledger_constants & constants, nano::generate_cache_flags const & = nano::generate_cache_flags{}); /** * Returns the account for a given hash * Returns std::nullopt if the block doesn't exist or has been pruned @@ -87,7 +88,7 @@ public: bool pruning{ false }; private: - void initialize (nano::generate_cache const &); + void initialize (nano::generate_cache_flags const &); }; std::unique_ptr collect_container_info (ledger & ledger, std::string const & name);