Skip to content

Commit

Permalink
Moving nano::store to nano::store::component.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Sep 20, 2023
1 parent 033a3a9 commit eca4d95
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 106 deletions.
2 changes: 1 addition & 1 deletion nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
5 changes: 4 additions & 1 deletion nano/lib/rep_weights.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

namespace nano
{
class store;
namespace store
{
class component;
}
class transaction;

class rep_weights
Expand Down
2 changes: 1 addition & 1 deletion nano/node/backlog_population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <nano/node/scheduler/priority.hpp>
#include <nano/store/component.hpp>

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 }
Expand Down
9 changes: 6 additions & 3 deletions nano/node/backlog_population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
namespace nano
{
class stats;
class store;
namespace store
{
class component;
}
class election_scheduler;

class backlog_population final
Expand All @@ -30,7 +33,7 @@ class backlog_population final
unsigned frequency;
};

backlog_population (const config &, nano::store &, nano::stats &);
backlog_population (const config &, nano::store::component &, nano::stats &);
~backlog_population ();

void start ();
Expand All @@ -50,7 +53,7 @@ class backlog_population final
callback_t activate_callback;

private: // Dependencies
nano::store & store;
nano::store::component & store;
nano::stats & stats;

config config_m;
Expand Down
2 changes: 1 addition & 1 deletion nano/node/bootstrap/bootstrap_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <nano/store/component.hpp>

// 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 },
Expand Down
6 changes: 3 additions & 3 deletions nano/node/bootstrap/bootstrap_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class bootstrap_server final
using request_t = std::pair<nano::asc_pull_req, std::shared_ptr<nano::transport::channel>>; // <request, response channel>

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 ();
Expand Down Expand Up @@ -71,7 +71,7 @@ class bootstrap_server final
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;
Expand All @@ -83,4 +83,4 @@ class bootstrap_server final
/** 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;
};
}
}
4 changes: 2 additions & 2 deletions nano/node/bootstrap_ascending/iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
{
Expand Down Expand Up @@ -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 }
Expand Down
13 changes: 8 additions & 5 deletions nano/node/bootstrap_ascending/iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

namespace nano
{
class store;
namespace store
{
class component;
}
class transaction;

namespace bootstrap_ascending
Expand All @@ -20,20 +23,20 @@ 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;
};

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
Expand All @@ -43,7 +46,7 @@ namespace bootstrap_ascending
void fill ();

private:
nano::store & store;
nano::store::component & store;
std::deque<nano::account> buffer;
bool warmup_m{ true };

Expand Down
4 changes: 2 additions & 2 deletions nano/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -1316,7 +1316,7 @@ std::unique_ptr<nano::inactive_node> 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);
Expand Down
2 changes: 1 addition & 1 deletion nano/node/epoch_upgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <nano/node/epoch_upgrader.hpp>
#include <nano/node/node.hpp>

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 },
Expand Down
11 changes: 7 additions & 4 deletions nano/node/epoch_upgrader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,25 @@ 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 ();

private: // Dependencies
nano::node & node;
nano::ledger & ledger;
nano::store & store;
nano::store::component & store;
nano::network_params & network_params;
nano::logger_mt & logger;

Expand All @@ -35,4 +38,4 @@ class epoch_upgrader final
std::atomic<bool> stopped{ false };
nano::locked<std::future<void>> epoch_upgrading;
};
}
}
2 changes: 1 addition & 1 deletion nano/node/lmdb/lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion nano/node/lmdb/lmdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nano/node/make_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <boost/filesystem/path.hpp>

std::unique_ptr<nano::store> 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::store::component> 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)
{
Expand Down
8 changes: 6 additions & 2 deletions nano/node/make_store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nano::store> 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<nano::store::component> 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);
}
1 change: 1 addition & 0 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <nano/node/telemetry.hpp>
#include <nano/node/websocket.hpp>
#include <nano/secure/buffer.hpp>
#include <nano/store/component.hpp>

#include <boost/filesystem.hpp>
#include <boost/property_tree/json_parser.hpp>
Expand Down
4 changes: 2 additions & 2 deletions nano/node/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class node final : public std::enable_shared_from_this<nano::node>
nano::work_pool & work;
nano::distributed_work_factory distributed_work;
nano::logger_mt logger;
std::unique_ptr<nano::store> store_impl;
nano::store & store;
std::unique_ptr<nano::store::component> store_impl;
nano::store::component & store;
nano::unchecked_map unchecked;
std::unique_ptr<nano::wallets_store> wallets_store_impl;
nano::wallets_store & wallets_store;
Expand Down
2 changes: 1 addition & 1 deletion nano/node/rocksdb/rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion nano/node/rocksdb/rocksdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion nano/node/vote_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<nano::lmdb::store *> (&store_a);
if (store_l != nullptr)
Expand Down
2 changes: 1 addition & 1 deletion nano/node/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class wallets final
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<nano::wallet_id, std::shared_ptr<nano::wallet>> get_wallets ();
nano::network_params & network_params;
Expand Down
2 changes: 1 addition & 1 deletion nano/rpc_test/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ std::shared_ptr<nano::node> 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;
Expand Down
7 changes: 5 additions & 2 deletions nano/rpc_test/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,7 +60,7 @@ namespace test
std::shared_ptr<nano::node> add_ipc_enabled_node (nano::test::system & system, nano::node_config & node_config, nano::node_flags const & node_flags);
std::shared_ptr<nano::node> add_ipc_enabled_node (nano::test::system & system, nano::node_config & node_config);
std::shared_ptr<nano::node> 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<double, std::nano> 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<double, std::nano> 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);
Expand Down
8 changes: 4 additions & 4 deletions nano/secure/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -695,12 +695,12 @@ class representative_visitor final : public nano::block_visitor
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)
Expand Down Expand Up @@ -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 },
Expand Down
Loading

0 comments on commit eca4d95

Please sign in to comment.