Move nano::generate_cache to its own file.
This commit is contained in:
parent
14c4c6ff71
commit
caef5dcabc
8 changed files with 39 additions and 30 deletions
|
|
@ -16,6 +16,7 @@
|
|||
#include <nano/node/vote_cache.hpp>
|
||||
#include <nano/node/websocketconfig.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/generate_cache_flags.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
9
nano/secure/generate_cache_flags.cpp
Normal file
9
nano/secure/generate_cache_flags.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include <nano/secure/generate_cache_flags.hpp>
|
||||
|
||||
void nano::generate_cache_flags::enable_all ()
|
||||
{
|
||||
reps = true;
|
||||
cemented_count = true;
|
||||
unchecked_count = true;
|
||||
account_count = true;
|
||||
}
|
||||
18
nano/secure/generate_cache_flags.hpp
Normal file
18
nano/secure/generate_cache_flags.hpp
Normal file
|
|
@ -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 ();
|
||||
};
|
||||
}
|
||||
|
|
@ -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<nano::account, nano::account_info> i, store::iterator<nano::account, nano::account_info> 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<nano::account, nano::confirmation_height_info> i, store::iterator<nano::account, nano::confirmation_height_info> n) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/generate_cache_flags.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
|
@ -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<container_info_component> collect_container_info (ledger & ledger, std::string const & name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue