From cec9adf98a06579dad2ad63b38e82b49b3c43a13 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Mon, 18 Sep 2023 02:48:24 +0100 Subject: [PATCH] Moving nano::store to nano::store::component. --- nano/core_test/ledger.cpp | 2 +- nano/lib/rep_weights.hpp | 5 +- nano/node/backlog_population.cpp | 2 +- nano/node/backlog_population.hpp | 9 +- nano/node/bootstrap/bootstrap_server.cpp | 2 +- nano/node/bootstrap/bootstrap_server.hpp | 6 +- nano/node/bootstrap_ascending/iterators.cpp | 4 +- nano/node/bootstrap_ascending/iterators.hpp | 13 +-- nano/node/cli.cpp | 4 +- nano/node/epoch_upgrader.cpp | 2 +- nano/node/epoch_upgrader.hpp | 11 ++- nano/node/lmdb/lmdb.cpp | 2 +- nano/node/lmdb/lmdb.hpp | 2 +- nano/node/make_store.cpp | 2 +- nano/node/make_store.hpp | 8 +- nano/node/node.cpp | 1 + nano/node/node.hpp | 4 +- nano/node/rocksdb/rocksdb.cpp | 2 +- nano/node/rocksdb/rocksdb.hpp | 2 +- nano/node/vote_processor.hpp | 5 +- nano/node/wallet.cpp | 2 +- nano/node/wallet.hpp | 2 +- nano/rpc_test/common.cpp | 2 +- nano/rpc_test/common.hpp | 7 +- nano/secure/ledger.cpp | 8 +- nano/secure/ledger.hpp | 9 +- nano/slow_test/node.cpp | 2 +- nano/store/component.cpp | 4 +- nano/store/component.hpp | 91 +++++++++++---------- nano/test_common/ledger.cpp | 2 +- nano/test_common/ledger.hpp | 9 +- 31 files changed, 129 insertions(+), 97 deletions(-) diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index fb995e52c..8118d3c3d 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -5558,7 +5558,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb) .build_shared (); nano::endpoint_key endpoint_key (address.to_bytes (), port); - auto version = nano::store::version_current; + auto version = nano::store::component::version_current; { auto transaction = store.tx_begin_write (); diff --git a/nano/lib/rep_weights.hpp b/nano/lib/rep_weights.hpp index 4647dd2a9..6073bdc76 100644 --- a/nano/lib/rep_weights.hpp +++ b/nano/lib/rep_weights.hpp @@ -9,7 +9,10 @@ namespace nano { -class store; +namespace store +{ + class component; +} class transaction; class rep_weights diff --git a/nano/node/backlog_population.cpp b/nano/node/backlog_population.cpp index 3222da3e3..3ab5a939a 100644 --- a/nano/node/backlog_population.cpp +++ b/nano/node/backlog_population.cpp @@ -4,7 +4,7 @@ #include #include -nano::backlog_population::backlog_population (const config & config_a, nano::store & store_a, nano::stats & stats_a) : +nano::backlog_population::backlog_population (const config & config_a, nano::store::component & store_a, nano::stats & stats_a) : config_m{ config_a }, store{ store_a }, stats{ stats_a } diff --git a/nano/node/backlog_population.hpp b/nano/node/backlog_population.hpp index 27d9fb5f3..7d678dd1a 100644 --- a/nano/node/backlog_population.hpp +++ b/nano/node/backlog_population.hpp @@ -12,7 +12,10 @@ namespace nano { class stats; -class store; +namespace store +{ + class component; +} class election_scheduler; class backlog_population final @@ -30,7 +33,7 @@ public: unsigned frequency; }; - backlog_population (const config &, nano::store &, nano::stats &); + backlog_population (const config &, nano::store::component &, nano::stats &); ~backlog_population (); void start (); @@ -50,7 +53,7 @@ public: callback_t activate_callback; private: // Dependencies - nano::store & store; + nano::store::component & store; nano::stats & stats; config config_m; diff --git a/nano/node/bootstrap/bootstrap_server.cpp b/nano/node/bootstrap/bootstrap_server.cpp index 87730a599..9a70a93fb 100644 --- a/nano/node/bootstrap/bootstrap_server.cpp +++ b/nano/node/bootstrap/bootstrap_server.cpp @@ -5,7 +5,7 @@ #include // TODO: Make threads configurable -nano::bootstrap_server::bootstrap_server (nano::store & store_a, nano::ledger & ledger_a, nano::network_constants const & network_constants_a, nano::stats & stats_a) : +nano::bootstrap_server::bootstrap_server (nano::store::component & store_a, nano::ledger & ledger_a, nano::network_constants const & network_constants_a, nano::stats & stats_a) : store{ store_a }, ledger{ ledger_a }, network_constants{ network_constants_a }, diff --git a/nano/node/bootstrap/bootstrap_server.hpp b/nano/node/bootstrap/bootstrap_server.hpp index b614661ad..2958e1633 100644 --- a/nano/node/bootstrap/bootstrap_server.hpp +++ b/nano/node/bootstrap/bootstrap_server.hpp @@ -29,7 +29,7 @@ public: using request_t = std::pair>; // public: - bootstrap_server (nano::store &, nano::ledger &, nano::network_constants const &, nano::stats &); + bootstrap_server (nano::store::component &, nano::ledger &, nano::network_constants const &, nano::stats &); ~bootstrap_server (); void start (); @@ -71,7 +71,7 @@ private: bool verify_request_type (nano::asc_pull_type) const; private: // Dependencies - nano::store & store; + nano::store::component & store; nano::ledger & ledger; nano::network_constants const & network_constants; nano::stats & stats; @@ -83,4 +83,4 @@ public: // Config /** Maximum number of blocks to send in a single response, cannot be higher than capacity of a single `asc_pull_ack` message */ constexpr static std::size_t max_blocks = nano::asc_pull_ack::blocks_payload::max_blocks; }; -} \ No newline at end of file +} diff --git a/nano/node/bootstrap_ascending/iterators.cpp b/nano/node/bootstrap_ascending/iterators.cpp index 30d39363b..3a8391bd3 100644 --- a/nano/node/bootstrap_ascending/iterators.cpp +++ b/nano/node/bootstrap_ascending/iterators.cpp @@ -7,7 +7,7 @@ * database_iterator */ -nano::bootstrap_ascending::database_iterator::database_iterator (nano::store & store_a, table_type table_a) : +nano::bootstrap_ascending::database_iterator::database_iterator (nano::store::component & store_a, table_type table_a) : store{ store_a }, table{ table_a } { @@ -57,7 +57,7 @@ void nano::bootstrap_ascending::database_iterator::next (nano::transaction & tx) * buffered_iterator */ -nano::bootstrap_ascending::buffered_iterator::buffered_iterator (nano::store & store_a) : +nano::bootstrap_ascending::buffered_iterator::buffered_iterator (nano::store::component & store_a) : store{ store_a }, accounts_iterator{ store, database_iterator::table_type::account }, pending_iterator{ store, database_iterator::table_type::pending } diff --git a/nano/node/bootstrap_ascending/iterators.hpp b/nano/node/bootstrap_ascending/iterators.hpp index 82285ecbd..82fdb60b1 100644 --- a/nano/node/bootstrap_ascending/iterators.hpp +++ b/nano/node/bootstrap_ascending/iterators.hpp @@ -6,7 +6,10 @@ namespace nano { -class store; +namespace store +{ + class component; +} class transaction; namespace bootstrap_ascending @@ -20,12 +23,12 @@ namespace bootstrap_ascending pending }; - explicit database_iterator (nano::store & store, table_type); + explicit database_iterator (nano::store::component & store, table_type); nano::account operator* () const; void next (nano::transaction & tx); private: - nano::store & store; + nano::store::component & store; nano::account current{ 0 }; const table_type table; }; @@ -33,7 +36,7 @@ namespace bootstrap_ascending class buffered_iterator { public: - explicit buffered_iterator (nano::store & store); + explicit buffered_iterator (nano::store::component & store); nano::account operator* () const; nano::account next (); // Indicates if a full ledger iteration has taken place e.g. warmed up @@ -43,7 +46,7 @@ namespace bootstrap_ascending void fill (); private: - nano::store & store; + nano::store::component & store; std::deque buffer; bool warmup_m{ true }; diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index a1dc89c54..0f9979d40 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -11,7 +11,7 @@ namespace { -void reset_confirmation_heights (nano::write_transaction const & transaction, nano::ledger_constants & constants, nano::store & store); +void reset_confirmation_heights (nano::write_transaction const & transaction, nano::ledger_constants & constants, nano::store::component & store); bool is_using_rocksdb (boost::filesystem::path const & data_path, boost::program_options::variables_map const & vm, std::error_code & ec); } @@ -1316,7 +1316,7 @@ std::unique_ptr nano::default_inactive_node (boost::filesys namespace { -void reset_confirmation_heights (nano::write_transaction const & transaction, nano::ledger_constants & constants, nano::store & store) +void reset_confirmation_heights (nano::write_transaction const & transaction, nano::ledger_constants & constants, nano::store::component & store) { // First do a clean sweep store.confirmation_height.clear (transaction); diff --git a/nano/node/epoch_upgrader.cpp b/nano/node/epoch_upgrader.cpp index 2064cf1f2..a731bb4da 100644 --- a/nano/node/epoch_upgrader.cpp +++ b/nano/node/epoch_upgrader.cpp @@ -2,7 +2,7 @@ #include #include -nano::epoch_upgrader::epoch_upgrader (nano::node & node_a, nano::ledger & ledger_a, nano::store & store_a, nano::network_params & network_params_a, nano::logger_mt & logger_a) : +nano::epoch_upgrader::epoch_upgrader (nano::node & node_a, nano::ledger & ledger_a, nano::store::component & store_a, nano::network_params & network_params_a, nano::logger_mt & logger_a) : node{ node_a }, ledger{ ledger_a }, store{ store_a }, diff --git a/nano/node/epoch_upgrader.hpp b/nano/node/epoch_upgrader.hpp index fb16b4d56..ab0499fb1 100644 --- a/nano/node/epoch_upgrader.hpp +++ b/nano/node/epoch_upgrader.hpp @@ -10,14 +10,17 @@ namespace nano { class node; class ledger; -class store; +namespace store +{ + class component; +} class network_params; class logger_mt; class epoch_upgrader final { public: - epoch_upgrader (nano::node &, nano::ledger &, nano::store &, nano::network_params &, nano::logger_mt &); + epoch_upgrader (nano::node &, nano::ledger &, nano::store::component &, nano::network_params &, nano::logger_mt &); bool start (nano::raw_key const & prv, nano::epoch epoch, uint64_t count_limit, uint64_t threads); void stop (); @@ -25,7 +28,7 @@ public: private: // Dependencies nano::node & node; nano::ledger & ledger; - nano::store & store; + nano::store::component & store; nano::network_params & network_params; nano::logger_mt & logger; @@ -35,4 +38,4 @@ private: std::atomic stopped{ false }; nano::locked> epoch_upgrading; }; -} \ No newline at end of file +} diff --git a/nano/node/lmdb/lmdb.cpp b/nano/node/lmdb/lmdb.cpp index 5a4bb4572..9bf16f0a1 100644 --- a/nano/node/lmdb/lmdb.cpp +++ b/nano/node/lmdb/lmdb.cpp @@ -42,7 +42,7 @@ void mdb_val::convert_buffer_to_value () nano::lmdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade_a) : // clang-format off - nano::store{ + nano::store::component{ block_store, frontier_store, account_store, diff --git a/nano/node/lmdb/lmdb.hpp b/nano/node/lmdb/lmdb.hpp index a73bbc235..ee7589699 100644 --- a/nano/node/lmdb/lmdb.hpp +++ b/nano/node/lmdb/lmdb.hpp @@ -44,7 +44,7 @@ namespace lmdb /** * mdb implementation of the block store */ - class store : public nano::store + class store : public nano::store::component { private: nano::lmdb::account_store account_store; diff --git a/nano/node/make_store.cpp b/nano/node/make_store.cpp index eb3667a25..c07f41dbe 100644 --- a/nano/node/make_store.cpp +++ b/nano/node/make_store.cpp @@ -4,7 +4,7 @@ #include -std::unique_ptr nano::make_store (nano::logger_mt & logger, boost::filesystem::path const & path, nano::ledger_constants & constants, bool read_only, bool add_db_postfix, nano::rocksdb_config const & rocksdb_config, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade) +std::unique_ptr nano::make_store (nano::logger_mt & logger, boost::filesystem::path const & path, nano::ledger_constants & constants, bool read_only, bool add_db_postfix, nano::rocksdb_config const & rocksdb_config, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade) { if (rocksdb_config.enable) { diff --git a/nano/node/make_store.hpp b/nano/node/make_store.hpp index 91192a798..c0521deba 100644 --- a/nano/node/make_store.hpp +++ b/nano/node/make_store.hpp @@ -17,11 +17,15 @@ namespace nano class ledger_constants; class lmdb_config; class rocksdb_config; -class store; class txn_tracking_config; } +namespace nano::store +{ +class component; +} + namespace nano { -std::unique_ptr make_store (nano::logger_mt & logger, boost::filesystem::path const & path, nano::ledger_constants & constants, bool open_read_only = false, bool add_db_postfix = true, nano::rocksdb_config const & rocksdb_config = nano::rocksdb_config{}, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false); +std::unique_ptr make_store (nano::logger_mt & logger, boost::filesystem::path const & path, nano::ledger_constants & constants, bool open_read_only = false, bool add_db_postfix = true, nano::rocksdb_config const & rocksdb_config = nano::rocksdb_config{}, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false); } diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 4d6a8e355..a9fb40a02 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/nano/node/node.hpp b/nano/node/node.hpp index e4753bb5f..b114c06ee 100644 --- a/nano/node/node.hpp +++ b/nano/node/node.hpp @@ -152,8 +152,8 @@ public: nano::work_pool & work; nano::distributed_work_factory distributed_work; nano::logger_mt logger; - std::unique_ptr store_impl; - nano::store & store; + std::unique_ptr store_impl; + nano::store::component & store; nano::unchecked_map unchecked; std::unique_ptr wallets_store_impl; nano::wallets_store & wallets_store; diff --git a/nano/node/rocksdb/rocksdb.cpp b/nano/node/rocksdb/rocksdb.cpp index 3d2fdb4df..6155811c3 100644 --- a/nano/node/rocksdb/rocksdb.cpp +++ b/nano/node/rocksdb/rocksdb.cpp @@ -63,7 +63,7 @@ void rocksdb_val::convert_buffer_to_value () nano::rocksdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::ledger_constants & constants, nano::rocksdb_config const & rocksdb_config_a, bool open_read_only_a) : // clang-format off - nano::store{ + nano::store::component{ block_store, frontier_store, account_store, diff --git a/nano/node/rocksdb/rocksdb.hpp b/nano/node/rocksdb/rocksdb.hpp index 5df0d9b4d..402fbcbba 100644 --- a/nano/node/rocksdb/rocksdb.hpp +++ b/nano/node/rocksdb/rocksdb.hpp @@ -37,7 +37,7 @@ namespace rocksdb /** * rocksdb implementation of the block store */ - class store : public nano::store + class store : public nano::store::component { private: nano::rocksdb::account_store account_store; diff --git a/nano/node/vote_processor.hpp b/nano/node/vote_processor.hpp index 16c72b2e0..ee8452abb 100644 --- a/nano/node/vote_processor.hpp +++ b/nano/node/vote_processor.hpp @@ -13,7 +13,10 @@ namespace nano { class signature_checker; class active_transactions; -class store; +namespace store +{ + class component; +} class node_observers; class stats; class node_config; diff --git a/nano/node/wallet.cpp b/nano/node/wallet.cpp index 804fe627e..ef17591b5 100644 --- a/nano/node/wallet.cpp +++ b/nano/node/wallet.cpp @@ -1696,7 +1696,7 @@ void nano::wallets::ongoing_compute_reps () }); } -void nano::wallets::split_if_needed (nano::transaction & transaction_destination, nano::store & store_a) +void nano::wallets::split_if_needed (nano::transaction & transaction_destination, nano::store::component & store_a) { auto store_l = dynamic_cast (&store_a); if (store_l != nullptr) diff --git a/nano/node/wallet.hpp b/nano/node/wallet.hpp index 1e81d441a..3c6581edc 100644 --- a/nano/node/wallet.hpp +++ b/nano/node/wallet.hpp @@ -213,7 +213,7 @@ public: bool check_rep (nano::account const &, nano::uint128_t const &, bool const = true); void compute_reps (); void ongoing_compute_reps (); - void split_if_needed (nano::transaction &, nano::store &); + void split_if_needed (nano::transaction &, nano::store::component &); void move_table (std::string const &, MDB_txn *, MDB_txn *); std::unordered_map> get_wallets (); nano::network_params & network_params; diff --git a/nano/rpc_test/common.cpp b/nano/rpc_test/common.cpp index 26629cc4a..dee28c8f7 100644 --- a/nano/rpc_test/common.cpp +++ b/nano/rpc_test/common.cpp @@ -102,7 +102,7 @@ std::shared_ptr nano::test::add_ipc_enabled_node (nano::test::system return add_ipc_enabled_node (system, node_config); } -void nano::test::reset_confirmation_height (nano::store & store, nano::account const & account) +void nano::test::reset_confirmation_height (nano::store::component & store, nano::account const & account) { auto transaction = store.tx_begin_write (); nano::confirmation_height_info confirmation_height_info; diff --git a/nano/rpc_test/common.hpp b/nano/rpc_test/common.hpp index bffc8ac8e..90d03129e 100644 --- a/nano/rpc_test/common.hpp +++ b/nano/rpc_test/common.hpp @@ -19,7 +19,10 @@ class node_flags; class node_rpc_config; class public_key; class rpc; -class store; +namespace store +{ + class component; +} using account = public_key; namespace ipc @@ -57,7 +60,7 @@ namespace test std::shared_ptr add_ipc_enabled_node (nano::test::system & system, nano::node_config & node_config, nano::node_flags const & node_flags); std::shared_ptr add_ipc_enabled_node (nano::test::system & system, nano::node_config & node_config); std::shared_ptr add_ipc_enabled_node (nano::test::system & system); - void reset_confirmation_height (nano::store & store, nano::account const & account); + void reset_confirmation_height (nano::store::component & store, nano::account const & account); void wait_response_impl (nano::test::system & system, rpc_context const & rpc_ctx, boost::property_tree::ptree & request, std::chrono::duration const & time, boost::property_tree::ptree & response_json); boost::property_tree::ptree wait_response (nano::test::system & system, rpc_context const & rpc_ctx, boost::property_tree::ptree & request, std::chrono::duration const & time = 5s); bool check_block_response_count (nano::test::system & system, rpc_context const & rpc_ctx, boost::property_tree::ptree & request, uint64_t size_count); diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 7495c1f5c..d46a7574f 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -686,7 +686,7 @@ ledger_processor::ledger_processor (nano::ledger & ledger_a, nano::write_transac class representative_visitor final : public nano::block_visitor { public: - representative_visitor (nano::transaction const & transaction_a, nano::store & store_a); + representative_visitor (nano::transaction const & transaction_a, nano::store::component & store_a); ~representative_visitor () = default; void compute (nano::block_hash const & hash_a); void send_block (nano::send_block const & block_a) override; @@ -695,12 +695,12 @@ public: void change_block (nano::change_block const & block_a) override; void state_block (nano::state_block const & block_a) override; nano::transaction const & transaction; - nano::store & store; + nano::store::component & store; nano::block_hash current; nano::block_hash result; }; -representative_visitor::representative_visitor (nano::transaction const & transaction_a, nano::store & store_a) : +representative_visitor::representative_visitor (nano::transaction const & transaction_a, nano::store::component & store_a) : transaction (transaction_a), store (store_a), result (0) @@ -744,7 +744,7 @@ void representative_visitor::state_block (nano::state_block const & block_a) } } // namespace -nano::ledger::ledger (nano::store & 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 const & generate_cache_a) : constants{ constants }, store{ store_a }, stats{ stat_a }, diff --git a/nano/secure/ledger.hpp b/nano/secure/ledger.hpp index 5d79a1210..f26ed6696 100644 --- a/nano/secure/ledger.hpp +++ b/nano/secure/ledger.hpp @@ -8,7 +8,10 @@ namespace nano { -class store; +namespace store +{ + class component; +} class stats; class write_transaction; @@ -27,7 +30,7 @@ public: class ledger final { public: - ledger (nano::store &, 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 const & = nano::generate_cache ()); /** * Return account containing hash, expects that block hash exists in ledger */ @@ -92,7 +95,7 @@ public: uint64_t height (nano::transaction const & transaction, nano::block_hash const & hash) const; static nano::uint128_t const unit; nano::ledger_constants & constants; - nano::store & store; + nano::store::component & store; nano::ledger_cache cache; nano::stats & stats; std::unordered_map bootstrap_weights; diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index 7cfea256f..5cdc56baa 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -26,7 +26,7 @@ using namespace std::chrono_literals; * function to count the block in the pruned store one by one * we manually count the blocks one by one because the rocksdb count feature is not accurate */ -size_t manually_count_pruned_blocks (nano::store & store) +size_t manually_count_pruned_blocks (nano::store::component & store) { size_t count = 0; auto transaction = store.tx_begin_read (); diff --git a/nano/store/component.cpp b/nano/store/component.cpp index 4fcd29845..d5f94d1cb 100644 --- a/nano/store/component.cpp +++ b/nano/store/component.cpp @@ -64,7 +64,7 @@ bool nano::write_transaction::contains (nano::tables table_a) const } // clang-format off -nano::store::store ( +nano::store::component::component ( nano::block_store & block_store_a, nano::frontier_store & frontier_store_a, nano::account_store & account_store_a, @@ -94,7 +94,7 @@ nano::store::store ( * If using a different store version than the latest then you may need * to modify some of the objects in the store to be appropriate for the version before an upgrade. */ -void nano::store::initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants) +void nano::store::component::initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants) { debug_assert (constants.genesis->has_sideband ()); debug_assert (account.begin (transaction_a) == account.end ()); diff --git a/nano/store/component.hpp b/nano/store/component.hpp index 89c86a74a..9b620d409 100644 --- a/nano/store/component.hpp +++ b/nano/store/component.hpp @@ -731,17 +731,19 @@ public: virtual void for_each_par (std::function, nano::store_iterator)> const & action_a) const = 0; }; -/** +namespace store +{ + /** * Store manager */ -class store -{ - friend class rocksdb_block_store_tombstone_count_Test; - friend class mdb_block_store_upgrade_v21_v22_Test; + class component + { + friend class rocksdb_block_store_tombstone_count_Test; + friend class mdb_block_store_upgrade_v21_v22_Test; -public: - // clang-format off - explicit store ( + public: + // clang-format off + explicit component ( nano::block_store &, nano::frontier_store &, nano::account_store &, @@ -753,51 +755,52 @@ public: nano::final_vote_store &, nano::version_store & ); - // clang-format on - virtual ~store () = default; - void initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants); - virtual uint64_t count (nano::transaction const & transaction_a, tables table_a) const = 0; - virtual int drop (nano::write_transaction const & transaction_a, tables table_a) = 0; - virtual bool not_found (int status) const = 0; - virtual bool success (int status) const = 0; - virtual int status_code_not_found () const = 0; - virtual std::string error_string (int status) const = 0; + // clang-format on + virtual ~component () = default; + void initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a, nano::ledger_constants & constants); + virtual uint64_t count (nano::transaction const & transaction_a, tables table_a) const = 0; + virtual int drop (nano::write_transaction const & transaction_a, tables table_a) = 0; + virtual bool not_found (int status) const = 0; + virtual bool success (int status) const = 0; + virtual int status_code_not_found () const = 0; + virtual std::string error_string (int status) const = 0; - block_store & block; - frontier_store & frontier; - account_store & account; - pending_store & pending; - static int constexpr version_minimum{ 14 }; - static int constexpr version_current{ 22 }; + block_store & block; + frontier_store & frontier; + account_store & account; + pending_store & pending; + static int constexpr version_minimum{ 14 }; + static int constexpr version_current{ 22 }; -public: - online_weight_store & online_weight; - pruned_store & pruned; - peer_store & peer; - confirmation_height_store & confirmation_height; - final_vote_store & final_vote; - version_store & version; + public: + online_weight_store & online_weight; + pruned_store & pruned; + peer_store & peer; + confirmation_height_store & confirmation_height; + final_vote_store & final_vote; + version_store & version; - virtual unsigned max_block_write_batch_num () const = 0; + virtual unsigned max_block_write_batch_num () const = 0; - virtual bool copy_db (boost::filesystem::path const & destination) = 0; - virtual void rebuild_db (nano::write_transaction const & transaction_a) = 0; + virtual bool copy_db (boost::filesystem::path const & destination) = 0; + virtual void rebuild_db (nano::write_transaction const & transaction_a) = 0; - /** Not applicable to all sub-classes */ - virtual void serialize_mdb_tracker (boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds){}; - virtual void serialize_memory_stats (boost::property_tree::ptree &) = 0; + /** Not applicable to all sub-classes */ + virtual void serialize_mdb_tracker (boost::property_tree::ptree &, std::chrono::milliseconds, std::chrono::milliseconds){}; + virtual void serialize_memory_stats (boost::property_tree::ptree &) = 0; - virtual bool init_error () const = 0; + virtual bool init_error () const = 0; - /** Start read-write transaction */ - virtual nano::write_transaction tx_begin_write (std::vector const & tables_to_lock = {}, std::vector const & tables_no_lock = {}) = 0; + /** Start read-write transaction */ + virtual nano::write_transaction tx_begin_write (std::vector const & tables_to_lock = {}, std::vector const & tables_no_lock = {}) = 0; - /** Start read-only transaction */ - virtual nano::read_transaction tx_begin_read () const = 0; + /** Start read-only transaction */ + virtual nano::read_transaction tx_begin_read () const = 0; - virtual std::string vendor_get () const = 0; -}; -} + virtual std::string vendor_get () const = 0; + }; +} // namespace store +} // namespace nano namespace std { diff --git a/nano/test_common/ledger.cpp b/nano/test_common/ledger.cpp index 840a463f8..a3337bc92 100644 --- a/nano/test_common/ledger.cpp +++ b/nano/test_common/ledger.cpp @@ -22,7 +22,7 @@ nano::ledger & nano::test::context::ledger_context::ledger () return ledger_m; } -nano::store & nano::test::context::ledger_context::store () +nano::store::component & nano::test::context::ledger_context::store () { return *store_m; } diff --git a/nano/test_common/ledger.hpp b/nano/test_common/ledger.hpp index 59ce59d78..17bafae68 100644 --- a/nano/test_common/ledger.hpp +++ b/nano/test_common/ledger.hpp @@ -7,7 +7,10 @@ namespace nano { -class store; +namespace store +{ + class component; +} namespace test { namespace context @@ -19,13 +22,13 @@ namespace test Blocks must all return process_result::progress when processed */ ledger_context (std::deque> && blocks = std::deque>{}); nano::ledger & ledger (); - nano::store & store (); + nano::store::component & store (); nano::stats & stats (); std::deque> const & blocks () const; private: nano::logger_mt logger; - std::unique_ptr store_m; + std::unique_ptr store_m; nano::stats stats_m; nano::ledger ledger_m; std::deque> blocks_m;