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 20, 2023
1 parent 1abcb38 commit 40cc5ae
Show file tree
Hide file tree
Showing 133 changed files with 2,916 additions and 2,919 deletions.
2 changes: 1 addition & 1 deletion nano/core_test/backlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST (backlog, population)
nano::test::system system{};
auto & node = *system.add_node ();

node.backlog.activate_callback.add ([&] (nano::transaction const & transaction, nano::account const & account, nano::account_info const & account_info, nano::confirmation_height_info const & conf_info) {
node.backlog.activate_callback.add ([&] (nano::store::transaction const & transaction, nano::account const & account, nano::account_info const & account_info, nano::confirmation_height_info const & conf_info) {
nano::lock_guard<nano::mutex> lock{ mutex };

activated.insert (account);
Expand Down
1,844 changes: 917 additions & 927 deletions nano/core_test/block_store.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nano/core_test/confirmation_height.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ TEST (confirmation_height, gap_bootstrap)
// Receive 2 comes in on the live network, however the chain has not been finished so it gets added to unchecked
node1.process_active (receive2);
// Waits for the unchecked_map to process the 4 blocks added to the block_processor, saving them in the unchecked table
auto check_block_is_listed = [&] (nano::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
auto check_block_is_listed = [&] (nano::store::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
return !node1.unchecked.get (block_hash_a).empty ();
};
ASSERT_TIMELY (5s, check_block_is_listed (node1.store.tx_begin_read (), receive2->previous ()));
Expand Down
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
6 changes: 3 additions & 3 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4495,7 +4495,7 @@ TEST (ledger, unchecked_receive)
node1.work_generate_blocking (*receive1);
node1.block_processor.add (send1);
node1.block_processor.add (receive1);
auto check_block_is_listed = [&] (nano::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
auto check_block_is_listed = [&] (nano::store::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
return !node1.unchecked.get (block_hash_a).empty ();
};
// Previous block for receive1 is unknown, signature cannot be validated
Expand Down 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
38 changes: 19 additions & 19 deletions nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ unsigned constexpr nano::wallet_store::version_current;
TEST (wallet, no_special_keys_accounts)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -36,7 +36,7 @@ TEST (wallet, no_special_keys_accounts)
TEST (wallet, no_key)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -51,7 +51,7 @@ TEST (wallet, no_key)
TEST (wallet, fetch_locked)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -73,7 +73,7 @@ TEST (wallet, fetch_locked)
TEST (wallet, retrieval)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -95,7 +95,7 @@ TEST (wallet, retrieval)
TEST (wallet, empty_iteration)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -109,7 +109,7 @@ TEST (wallet, empty_iteration)
TEST (wallet, one_item_iteration)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -131,7 +131,7 @@ TEST (wallet, one_item_iteration)
TEST (wallet, two_item_iteration)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
nano::keypair key1;
nano::keypair key2;
Expand Down Expand Up @@ -270,7 +270,7 @@ TEST (wallet, spend_no_previous)
TEST (wallet, find_none)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -283,7 +283,7 @@ TEST (wallet, find_none)
TEST (wallet, find_existing)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -302,7 +302,7 @@ TEST (wallet, find_existing)
TEST (wallet, rekey)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -374,7 +374,7 @@ TEST (account, encode_fail)
TEST (wallet, hash_password)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -423,7 +423,7 @@ TEST (fan, change)
TEST (wallet, reopen_default_password)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
auto transaction (env.tx_begin_write ());
ASSERT_FALSE (init);
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -459,7 +459,7 @@ TEST (wallet, reopen_default_password)
TEST (wallet, representative)
{
auto error (false);
nano::mdb_env env (error, nano::unique_path ());
nano::store::lmdb::env env (error, nano::unique_path ());
ASSERT_FALSE (error);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -480,7 +480,7 @@ TEST (wallet, representative)
TEST (wallet, serialize_json_empty)
{
auto error (false);
nano::mdb_env env (error, nano::unique_path ());
nano::store::lmdb::env env (error, nano::unique_path ());
ASSERT_FALSE (error);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand All @@ -505,7 +505,7 @@ TEST (wallet, serialize_json_empty)
TEST (wallet, serialize_json_one)
{
auto error (false);
nano::mdb_env env (error, nano::unique_path ());
nano::store::lmdb::env env (error, nano::unique_path ());
ASSERT_FALSE (error);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -534,7 +534,7 @@ TEST (wallet, serialize_json_one)
TEST (wallet, serialize_json_password)
{
auto error (false);
nano::mdb_env env (error, nano::unique_path ());
nano::store::lmdb::env env (error, nano::unique_path ());
ASSERT_FALSE (error);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -567,7 +567,7 @@ TEST (wallet, serialize_json_password)
TEST (wallet_store, move)
{
auto error (false);
nano::mdb_env env (error, nano::unique_path ());
nano::store::lmdb::env env (error, nano::unique_path ());
ASSERT_FALSE (error);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -725,7 +725,7 @@ TEST (wallet, insert_locked)
TEST (wallet, deterministic_keys)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down Expand Up @@ -768,7 +768,7 @@ TEST (wallet, deterministic_keys)
TEST (wallet, reseed)
{
bool init;
nano::mdb_env env (init, nano::unique_path ());
nano::store::lmdb::env env (init, nano::unique_path ());
ASSERT_FALSE (init);
auto transaction (env.tx_begin_write ());
nano::kdf kdf{ nano::dev::network_params.kdf_work };
Expand Down
10 changes: 5 additions & 5 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ int main (int argc, char * const * argv)
for (; i != end; ++i)
{
nano::block_hash hash = i->first;
nano::block_w_sideband sideband = i->second;
nano::store::block_w_sideband sideband = i->second;
std::shared_ptr<nano::block> b = sideband.block;
std::cout << hash.to_string () << std::endl
<< b->to_json ();
Expand Down Expand Up @@ -1408,7 +1408,7 @@ int main (int argc, char * const * argv)
}
};

auto check_account = [&print_error_message, &silent, &count, &block_count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
auto check_account = [&print_error_message, &silent, &count, &block_count] (std::shared_ptr<nano::node> const & node, nano::store::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
++count;
if (!silent && (count % 20000) == 0)
{
Expand Down Expand Up @@ -1682,7 +1682,7 @@ int main (int argc, char * const * argv)
finished = false;
std::deque<std::pair<nano::pending_key, nano::pending_info>> pending;

auto check_pending = [&print_error_message, &silent, &count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
auto check_pending = [&print_error_message, &silent, &count] (std::shared_ptr<nano::node> const & node, nano::store::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
++count;
if (!silent && (count % 500000) == 0)
{
Expand Down Expand Up @@ -1916,7 +1916,7 @@ int main (int argc, char * const * argv)
nano::locked<std::vector<boost::unordered_set<nano::account>>> opened_account_versions_shared (epoch_count);
using opened_account_versions_t = decltype (opened_account_versions_shared)::value_type;
node->store.account.for_each_par (
[&opened_account_versions_shared, epoch_count] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
[&opened_account_versions_shared, epoch_count] (nano::store::read_transaction const & /*unused*/, nano::store::iterator<nano::account, nano::account_info> i, nano::store::iterator<nano::account, nano::account_info> n) {
// First cache locally
opened_account_versions_t opened_account_versions_l (epoch_count);
for (; i != n; ++i)
Expand Down Expand Up @@ -1953,7 +1953,7 @@ int main (int argc, char * const * argv)
nano::locked<boost::unordered_map<nano::account, std::underlying_type_t<nano::epoch>>> unopened_highest_pending_shared;
using unopened_highest_pending_t = decltype (unopened_highest_pending_shared)::value_type;
node->store.pending.for_each_par (
[&unopened_highest_pending_shared, &opened_accounts] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::pending_key, nano::pending_info> i, nano::store_iterator<nano::pending_key, nano::pending_info> n) {
[&unopened_highest_pending_shared, &opened_accounts] (nano::store::read_transaction const & /*unused*/, nano::store::iterator<nano::pending_key, nano::pending_info> i, nano::store::iterator<nano::pending_key, nano::pending_info> n) {
// First cache locally
unopened_highest_pending_t unopened_highest_pending_l;
for (; i != n; ++i)
Expand Down
2 changes: 1 addition & 1 deletion nano/node/active_transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ bool nano::active_transactions::publish (std::shared_ptr<nano::block> const & bl
}

// Returns the type of election status requiring callbacks calling later
boost::optional<nano::election_status_type> nano::active_transactions::confirm_block (nano::transaction const & transaction_a, std::shared_ptr<nano::block> const & block_a)
boost::optional<nano::election_status_type> nano::active_transactions::confirm_block (store::transaction const & transaction_a, std::shared_ptr<nano::block> const & block_a)
{
auto const hash = block_a->hash ();
std::shared_ptr<nano::election> election = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion nano/node/active_transactions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class active_transactions final
bool empty () const;
std::size_t size () const;
bool publish (std::shared_ptr<nano::block> const &);
boost::optional<nano::election_status_type> confirm_block (nano::transaction const &, std::shared_ptr<nano::block> const &);
boost::optional<nano::election_status_type> confirm_block (store::transaction const &, std::shared_ptr<nano::block> const &);
void block_cemented_callback (std::shared_ptr<nano::block> const &);
void block_already_cemented_callback (nano::block_hash const &);

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 @@ -111,7 +111,7 @@ void nano::backlog_population::populate_backlog (nano::unique_lock<nano::mutex>
}
}

void nano::backlog_population::activate (nano::transaction const & transaction, nano::account const & account)
void nano::backlog_population::activate (store::transaction const & transaction, nano::account const & account)
{
debug_assert (!activate_callback.empty ());

Expand Down
15 changes: 8 additions & 7 deletions nano/node/backlog_population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
#include <condition_variable>
#include <thread>

namespace nano::store
{
class component;
class transaction;
}
namespace nano
{
class stats;
namespace store
{
class component;
}
class election_scheduler;

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

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

void start ();
Expand All @@ -49,7 +50,7 @@ class backlog_population final
/**
* Callback called for each backlogged account
*/
using callback_t = nano::observer_set<nano::transaction const &, nano::account const &, nano::account_info const &, nano::confirmation_height_info const &>;
using callback_t = nano::observer_set<store::transaction const &, nano::account const &, nano::account_info const &, nano::confirmation_height_info const &>;
callback_t activate_callback;

private: // Dependencies
Expand All @@ -63,7 +64,7 @@ class backlog_population final
bool predicate () const;

void populate_backlog (nano::unique_lock<nano::mutex> & lock);
void activate (nano::transaction const &, nano::account const &);
void activate (store::transaction const &, nano::account const &);

/** This is a manual trigger, the ongoing backlog population does not use this.
* It can be triggered even when backlog population (frontiers confirmation) is disabled. */
Expand Down
6 changes: 3 additions & 3 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ std::optional<nano::process_return> nano::block_processor::add_blocking (std::sh
return result;
}

void nano::block_processor::rollback_competitor (nano::write_transaction const & transaction, nano::block const & block)
void nano::block_processor::rollback_competitor (store::write_transaction const & transaction, nano::block const & block)
{
auto hash = block.hash ();
auto successor = node.ledger.successor (transaction, block.qualified_root ());
Expand Down Expand Up @@ -314,7 +314,7 @@ auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock
return processed;
}

nano::process_return nano::block_processor::process_one (nano::write_transaction const & transaction_a, std::shared_ptr<nano::block> block, bool const forced_a)
nano::process_return nano::block_processor::process_one (store::write_transaction const & transaction_a, std::shared_ptr<nano::block> block, bool const forced_a)
{
nano::process_return result;
auto hash (block->hash ());
Expand Down Expand Up @@ -460,7 +460,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
return result;
}

void nano::block_processor::queue_unchecked (nano::write_transaction const & transaction_a, nano::hash_or_account const & hash_or_account_a)
void nano::block_processor::queue_unchecked (store::write_transaction const & transaction_a, nano::hash_or_account const & hash_or_account_a)
{
node.unchecked.trigger (hash_or_account_a);
node.gap_cache.erase (hash_or_account_a.hash);
Expand Down
11 changes: 8 additions & 3 deletions nano/node/blockprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <memory>
#include <thread>

namespace nano::store
{
class write_transaction;
}

namespace nano
{
class node;
Expand Down Expand Up @@ -53,9 +58,9 @@ class block_processor final

private:
// Roll back block in the ledger that conflicts with 'block'
void rollback_competitor (nano::write_transaction const & transaction, nano::block const & block);
nano::process_return process_one (nano::write_transaction const &, std::shared_ptr<nano::block> block, bool const = false);
void queue_unchecked (nano::write_transaction const &, nano::hash_or_account const &);
void rollback_competitor (store::write_transaction const & transaction, nano::block const & block);
nano::process_return process_one (store::write_transaction const &, std::shared_ptr<nano::block> block, bool const = false);
void queue_unchecked (store::write_transaction const &, nano::hash_or_account const &);
std::deque<processed_t> process_batch (nano::unique_lock<nano::mutex> &);
void process_verified_state_blocks (std::deque<nano::state_block_signature_verification::value_type> &, std::vector<int> const &, std::vector<nano::block_hash> const &, std::vector<nano::signature> const &);
void add_impl (std::shared_ptr<nano::block> block);
Expand Down
2 changes: 1 addition & 1 deletion nano/node/bootstrap/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ bool nano::bootstrap_initiator::in_progress ()
return !attempts_list.empty ();
}

void nano::bootstrap_initiator::block_processed (nano::transaction const & tx, nano::process_return const & result, nano::block const & block)
void nano::bootstrap_initiator::block_processed (store::transaction const & tx, nano::process_return const & result, nano::block const & block)
{
nano::lock_guard<nano::mutex> lock{ mutex };
for (auto & i : attempts_list)
Expand Down
Loading

0 comments on commit 40cc5ae

Please sign in to comment.