Skip to content

Commit

Permalink
Rename classes to be under namespace nano::store
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Sep 19, 2023
1 parent e8f3367 commit cddc0c3
Show file tree
Hide file tree
Showing 63 changed files with 2,029 additions and 2,039 deletions.
1,836 changes: 913 additions & 923 deletions nano/core_test/block_store.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions nano/core_test/gap_cache.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <nano/store/block.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5543,7 +5543,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
nano::logger_mt logger{};
boost::asio::ip::address_v6 address (boost::asio::ip::make_address_v6 ("::ffff:127.0.0.1"));
uint16_t port = 100;
nano::lmdb::store store{ logger, path / "data.ldb", nano::dev::constants };
nano::store::lmdb::component store{ logger, path / "data.ldb", nano::dev::constants };
nano::ledger ledger{ store, system.stats, nano::dev::constants };
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };

Expand Down Expand Up @@ -5583,7 +5583,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
auto error = ledger.migrate_lmdb_to_rocksdb (path);
ASSERT_FALSE (error);

nano::rocksdb::store rocksdb_store{ logger, path / "rocksdb", nano::dev::constants };
nano::store::rocksdb::component rocksdb_store{ logger, path / "rocksdb", nano::dev::constants };
auto rocksdb_transaction (rocksdb_store.tx_begin_read ());

nano::pending_info pending_info{};
Expand Down
4 changes: 2 additions & 2 deletions nano/node/make_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ std::unique_ptr<nano::store::component> nano::make_store (nano::logger_mt & logg
{
if (rocksdb_config.enable)
{
return std::make_unique<nano::rocksdb::store> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only);
return std::make_unique<nano::store::rocksdb::component> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only);
}

return std::make_unique<nano::lmdb::store> (logger, add_db_postfix ? path / "data.ldb" : path, constants, txn_tracking_config_a, block_processor_batch_max_time_a, lmdb_config_a, backup_before_upgrade);
return std::make_unique<nano::store::lmdb::component> (logger, add_db_postfix ? path / "data.ldb" : path, constants, txn_tracking_config_a, block_processor_batch_max_time_a, lmdb_config_a, backup_before_upgrade);
}
4 changes: 2 additions & 2 deletions nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ nano::wallets::wallets (bool error_a, nano::node & node_a) :
char const * store_path;
mdb_env_get_path (env, &store_path);
boost::filesystem::path const path (store_path);
nano::lmdb::store::create_backup_file (env, path, node_a.logger);
nano::store::lmdb::component::create_backup_file (env, path, node_a.logger);
}
for (auto & item : items)
{
Expand Down Expand Up @@ -1698,7 +1698,7 @@ void nano::wallets::ongoing_compute_reps ()

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);
auto store_l = dynamic_cast<nano::store::lmdb::component *> (&store_a);
if (store_l != nullptr)
{
if (items.empty ())
Expand Down
2 changes: 1 addition & 1 deletion nano/store/account.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/store/account.hpp>

std::optional<nano::account_info> nano::account_store::get (nano::transaction const & transaction, nano::account const & account)
std::optional<nano::account_info> nano::store::account::get (nano::transaction const & transaction, nano::account const & account)
{
nano::account_info info;
bool error = get (transaction, account, info);
Expand Down
4 changes: 2 additions & 2 deletions nano/store/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class read_transaction;
class transaction;
class write_transaction;
}
namespace nano
namespace nano::store
{
/**
* Manages account storage and iteration
*/
class account_store
class account
{
public:
virtual void put (nano::write_transaction const &, nano::account const &, nano::account_info const &) = 0;
Expand Down
4 changes: 2 additions & 2 deletions nano/store/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class read_transaction;
class transaction;
class write_transaction;
}
namespace nano
namespace nano::store
{
/**
* Manages block storage and iteration
*/
class block_store
class block
{
public:
virtual void put (nano::write_transaction const &, nano::block_hash const &, nano::block const &) = 0;
Expand Down
20 changes: 10 additions & 10 deletions nano/store/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ bool nano::write_transaction::contains (nano::tables table_a) const

// clang-format off
nano::store::component::component (
nano::block_store & block_store_a,
nano::frontier_store & frontier_store_a,
nano::account_store & account_store_a,
nano::pending_store & pending_store_a,
nano::online_weight_store & online_weight_store_a,
nano::pruned_store & pruned_store_a,
nano::peer_store & peer_store_a,
nano::confirmation_height_store & confirmation_height_store_a,
nano::final_vote_store & final_vote_store_a,
nano::version_store & version_store_a
nano::store::block & block_store_a,
nano::store::frontier & frontier_store_a,
nano::store::account & account_store_a,
nano::store::pending & pending_store_a,
nano::store::online_weight & online_weight_store_a,
nano::store::pruned & pruned_store_a,
nano::store::peer & peer_store_a,
nano::store::confirmation_height & confirmation_height_store_a,
nano::store::final_vote & final_vote_store_a,
nano::store::version & version_store_a
) :
block (block_store_a),
frontier (frontier_store_a),
Expand Down
63 changes: 33 additions & 30 deletions nano/store/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,20 @@ class write_transaction final : public transaction
std::unique_ptr<nano::write_transaction_impl> impl;
};

class account_store;
class block_store;
class confirmation_height_store;
class final_vote_store;
class frontier_store;
namespace store
{
class account;
class block;
class confirmation_height;
class final_vote;
class frontier;
class online_weight;
class peer;
class pending;
class pruned;
class version;
}
class ledger_cache;
class online_weight_store;
class peer_store;
class pending_store;
class pruned_store;
class version_store;

namespace store
{
Expand All @@ -526,16 +529,16 @@ namespace store
public:
// clang-format off
explicit component (
nano::block_store &,
nano::frontier_store &,
nano::account_store &,
nano::pending_store &,
nano::online_weight_store &,
nano::pruned_store &,
nano::peer_store &,
nano::confirmation_height_store &,
nano::final_vote_store &,
nano::version_store &
nano::store::block &,
nano::store::frontier &,
nano::store::account &,
nano::store::pending &,
nano::store::online_weight&,
nano::store::pruned &,
nano::store::peer &,
nano::store::confirmation_height &,
nano::store::final_vote &,
nano::store::version &
);
// clang-format on
virtual ~component () = default;
Expand All @@ -547,20 +550,20 @@ namespace store
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;
store::block & block;
store::frontier & frontier;
store::account & account;
store::pending & 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;
store::online_weight & online_weight;
store::pruned & pruned;
store::peer & peer;
store::confirmation_height & confirmation_height;
store::final_vote & final_vote;
store::version & version;

virtual unsigned max_block_write_batch_num () const = 0;

Expand Down
2 changes: 1 addition & 1 deletion nano/store/confirmation_height.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/store/confirmation_height.hpp>

std::optional<nano::confirmation_height_info> nano::confirmation_height_store::get (nano::transaction const & transaction, nano::account const & account)
std::optional<nano::confirmation_height_info> nano::store::confirmation_height::get (nano::transaction const & transaction, nano::account const & account)
{
nano::confirmation_height_info info;
bool error = get (transaction, account, info);
Expand Down
4 changes: 2 additions & 2 deletions nano/store/confirmation_height.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class read_transaction;
class transaction;
class write_transaction;
}
namespace nano
namespace nano::store
{
/**
* Manages confirmation height storage and iteration
*/
class confirmation_height_store
class confirmation_height
{
public:
virtual void put (nano::write_transaction const & transaction_a, nano::account const & account_a, nano::confirmation_height_info const & confirmation_height_info_a) = 0;
Expand Down
4 changes: 2 additions & 2 deletions nano/store/final.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class read_transaction;
class transaction;
class write_transaction;
}
namespace nano
namespace nano::store
{
/**
* Manages final vote storage and iteration
*/
class final_vote_store
class final_vote
{
public:
virtual bool put (nano::write_transaction const & transaction_a, nano::qualified_root const & root_a, nano::block_hash const & hash_a) = 0;
Expand Down
4 changes: 2 additions & 2 deletions nano/store/frontier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class read_transaction;
class transaction;
class write_transaction;
}
namespace nano
namespace nano::store
{
/**
* Manages frontier storage and iteration
*/
class frontier_store
class frontier
{
public:
virtual void put (nano::write_transaction const &, nano::block_hash const &, nano::account const &) = 0;
Expand Down
22 changes: 11 additions & 11 deletions nano/store/lmdb/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#include <nano/store/lmdb/account.hpp>
#include <nano/store/lmdb/lmdb.hpp>

nano::lmdb::account_store::account_store (nano::lmdb::store & store_a) :
nano::store::lmdb::account::account (nano::store::lmdb::component & store_a) :
store (store_a){};

void nano::lmdb::account_store::put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info)
void nano::store::lmdb::account::put (nano::write_transaction const & transaction, nano::account const & account, nano::account_info const & info)
{
auto status = store.put (transaction, tables::accounts, account, info);
store.release_assert_success (status);
}

bool nano::lmdb::account_store::get (nano::transaction const & transaction, nano::account const & account, nano::account_info & info)
bool nano::store::lmdb::account::get (nano::transaction const & transaction, nano::account const & account, nano::account_info & info)
{
nano::mdb_val value;
auto status1 (store.get (transaction, tables::accounts, account, value));
Expand All @@ -25,44 +25,44 @@ bool nano::lmdb::account_store::get (nano::transaction const & transaction, nano
return result;
}

void nano::lmdb::account_store::del (nano::write_transaction const & transaction_a, nano::account const & account_a)
void nano::store::lmdb::account::del (nano::write_transaction const & transaction_a, nano::account const & account_a)
{
auto status = store.del (transaction_a, tables::accounts, account_a);
store.release_assert_success (status);
}

bool nano::lmdb::account_store::exists (nano::transaction const & transaction_a, nano::account const & account_a)
bool nano::store::lmdb::account::exists (nano::transaction const & transaction_a, nano::account const & account_a)
{
auto iterator (begin (transaction_a, account_a));
return iterator != end () && nano::account (iterator->first) == account_a;
}

size_t nano::lmdb::account_store::count (nano::transaction const & transaction_a)
size_t nano::store::lmdb::account::count (nano::transaction const & transaction_a)
{
return store.count (transaction_a, tables::accounts);
}

nano::store_iterator<nano::account, nano::account_info> nano::lmdb::account_store::begin (nano::transaction const & transaction, nano::account const & account) const
nano::store_iterator<nano::account, nano::account_info> nano::store::lmdb::account::begin (nano::transaction const & transaction, nano::account const & account) const
{
return store.make_iterator<nano::account, nano::account_info> (transaction, tables::accounts, account);
}

nano::store_iterator<nano::account, nano::account_info> nano::lmdb::account_store::begin (nano::transaction const & transaction) const
nano::store_iterator<nano::account, nano::account_info> nano::store::lmdb::account::begin (nano::transaction const & transaction) const
{
return store.make_iterator<nano::account, nano::account_info> (transaction, tables::accounts);
}

nano::store_iterator<nano::account, nano::account_info> nano::lmdb::account_store::rbegin (nano::transaction const & transaction_a) const
nano::store_iterator<nano::account, nano::account_info> nano::store::lmdb::account::rbegin (nano::transaction const & transaction_a) const
{
return store.make_iterator<nano::account, nano::account_info> (transaction_a, tables::accounts, false);
}

nano::store_iterator<nano::account, nano::account_info> nano::lmdb::account_store::end () const
nano::store_iterator<nano::account, nano::account_info> nano::store::lmdb::account::end () const
{
return nano::store_iterator<nano::account, nano::account_info> (nullptr);
}

void nano::lmdb::account_store::for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const & action_a) const
void nano::store::lmdb::account::for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::account, nano::account_info>, nano::store_iterator<nano::account, nano::account_info>)> const & action_a) const
{
parallel_traversal<nano::uint256_t> (
[&action_a, this] (nano::uint256_t const & start, nano::uint256_t const & end, bool const is_last) {
Expand Down
Loading

0 comments on commit cddc0c3

Please sign in to comment.