Remove store dependency from unchecked_map
This commit is contained in:
parent
d3fcc4dcc6
commit
fdcf0b17cb
6 changed files with 19 additions and 46 deletions
|
@ -447,9 +447,7 @@ TEST (block_store, empty_bootstrap)
|
|||
{
|
||||
nano::test::system system{};
|
||||
nano::logger_mt logger;
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
size_t count = 0;
|
||||
unchecked.for_each ([&count] (nano::unchecked_key const & key, nano::unchecked_info const & info) {
|
||||
++count;
|
||||
|
@ -961,6 +959,7 @@ TEST (block_store, pruned_random)
|
|||
ASSERT_EQ (hash1, random_hash);
|
||||
}
|
||||
|
||||
/* This test has no code to test.
|
||||
namespace nano
|
||||
{
|
||||
namespace lmdb
|
||||
|
@ -1008,6 +1007,7 @@ namespace lmdb
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
TEST (block_store, state_block)
|
||||
{
|
||||
|
|
|
@ -5541,7 +5541,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
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::unchecked_map unchecked{ store, system.stats, false };
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
nano::ledger ledger{ store, system.stats, nano::dev::constants };
|
||||
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
|
||||
|
||||
|
@ -5582,7 +5582,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
ASSERT_FALSE (error);
|
||||
|
||||
nano::rocksdb::store rocksdb_store{ logger, path / "rocksdb", nano::dev::constants };
|
||||
nano::unchecked_map rocksdb_unchecked{ rocksdb_store, system.stats, false };
|
||||
nano::unchecked_map rocksdb_unchecked{ system.stats, false };
|
||||
auto rocksdb_transaction (rocksdb_store.tx_begin_read ());
|
||||
|
||||
nano::pending_info pending_info{};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <nano/lib/logger_mt.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/unchecked_map.hpp>
|
||||
#include <nano/secure/store.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/system.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
@ -19,13 +19,10 @@ class context
|
|||
{
|
||||
public:
|
||||
context () :
|
||||
store{ nano::make_store (logger, nano::unique_path (), nano::dev::constants) },
|
||||
unchecked{ *store, stats, false }
|
||||
unchecked{ stats, false }
|
||||
{
|
||||
}
|
||||
nano::logger_mt logger;
|
||||
nano::stats stats;
|
||||
std::unique_ptr<nano::store> store;
|
||||
nano::unchecked_map unchecked;
|
||||
};
|
||||
std::shared_ptr<nano::block> block ()
|
||||
|
@ -58,10 +55,7 @@ TEST (unchecked_map, put_one)
|
|||
TEST (block_store, one_bootstrap)
|
||||
{
|
||||
nano::test::system system{};
|
||||
nano::logger_mt logger{};
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
nano::block_builder builder;
|
||||
auto block1 = builder
|
||||
.send ()
|
||||
|
@ -72,12 +66,11 @@ TEST (block_store, one_bootstrap)
|
|||
.work (5)
|
||||
.build_shared ();
|
||||
unchecked.put (block1->hash (), nano::unchecked_info{ block1 });
|
||||
auto check_block_is_listed = [&] (nano::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
|
||||
auto check_block_is_listed = [&] (nano::block_hash const & block_hash_a) {
|
||||
return unchecked.get (block_hash_a).size () > 0;
|
||||
};
|
||||
// Waits for the block1 to get saved in the database
|
||||
ASSERT_TIMELY (10s, check_block_is_listed (store->tx_begin_read (), block1->hash ()));
|
||||
auto transaction = store->tx_begin_read ();
|
||||
ASSERT_TIMELY (10s, check_block_is_listed (block1->hash ()));
|
||||
std::vector<nano::block_hash> dependencies;
|
||||
unchecked.for_each ([&dependencies] (nano::unchecked_key const & key, nano::unchecked_info const & info) {
|
||||
dependencies.push_back (key.key ());
|
||||
|
@ -95,10 +88,7 @@ TEST (block_store, one_bootstrap)
|
|||
TEST (unchecked, simple)
|
||||
{
|
||||
nano::test::system system{};
|
||||
nano::logger_mt logger{};
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.send ()
|
||||
|
@ -139,10 +129,7 @@ TEST (unchecked, multiple)
|
|||
// Don't test this in rocksdb mode
|
||||
GTEST_SKIP ();
|
||||
}
|
||||
nano::logger_mt logger{};
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.send ()
|
||||
|
@ -172,10 +159,7 @@ TEST (unchecked, multiple)
|
|||
TEST (unchecked, double_put)
|
||||
{
|
||||
nano::test::system system{};
|
||||
nano::logger_mt logger{};
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.send ()
|
||||
|
@ -206,10 +190,7 @@ TEST (unchecked, double_put)
|
|||
TEST (unchecked, multiple_get)
|
||||
{
|
||||
nano::test::system system{};
|
||||
nano::logger_mt logger{};
|
||||
auto store = nano::make_store (logger, nano::unique_path (), nano::dev::constants);
|
||||
nano::unchecked_map unchecked{ *store, system.stats, false };
|
||||
ASSERT_TRUE (!store->init_error ());
|
||||
nano::unchecked_map unchecked{ system.stats, false };
|
||||
// Instantiates three blocks
|
||||
nano::block_builder builder;
|
||||
auto block1 = builder
|
||||
|
@ -248,7 +229,7 @@ TEST (unchecked, multiple_get)
|
|||
|
||||
// count the number of blocks in the unchecked table by counting them one by one
|
||||
// we cannot trust the count() method if the backend is rocksdb
|
||||
auto count_unchecked_blocks_one_by_one = [&store, &unchecked] () {
|
||||
auto count_unchecked_blocks_one_by_one = [&unchecked] () {
|
||||
size_t count = 0;
|
||||
unchecked.for_each ([&count] (nano::unchecked_key const & key, nano::unchecked_info const & info) {
|
||||
++count;
|
||||
|
|
|
@ -159,7 +159,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, boost::filesystem::path co
|
|||
logger (config_a.logging.min_time_between_log_output),
|
||||
store_impl (nano::make_store (logger, application_path_a, network_params.ledger, flags.read_only, true, config_a.rocksdb_config, config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_config, config_a.backup_before_upgrade)),
|
||||
store (*store_impl),
|
||||
unchecked{ store, stats, flags.disable_block_processor_unchecked_deletion },
|
||||
unchecked{ stats, flags.disable_block_processor_unchecked_deletion },
|
||||
wallets_store_impl (std::make_unique<nano::mdb_wallets_store> (application_path_a / "wallets.ldb", config_a.lmdb_config)),
|
||||
wallets_store (*wallets_store_impl),
|
||||
gap_cache (*this),
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/node/unchecked_map.hpp>
|
||||
#include <nano/secure/store.hpp>
|
||||
|
||||
nano::unchecked_map::unchecked_map (nano::store & store, nano::stats & stats, bool const & disable_delete) :
|
||||
store{ store },
|
||||
nano::unchecked_map::unchecked_map (nano::stats & stats, bool const & disable_delete) :
|
||||
stats{ stats },
|
||||
disable_delete{ disable_delete },
|
||||
thread{ [this] () { run (); } }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <nano/lib/locks.hpp>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/observer_set.hpp>
|
||||
#include <nano/secure/store.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
|
@ -18,16 +18,11 @@ namespace mi = boost::multi_index;
|
|||
namespace nano
|
||||
{
|
||||
class stats;
|
||||
class store;
|
||||
class transaction;
|
||||
class unchecked_info;
|
||||
class unchecked_key;
|
||||
class write_transaction;
|
||||
|
||||
class unchecked_map
|
||||
{
|
||||
public:
|
||||
unchecked_map (nano::store &, nano::stats &, bool const & do_delete);
|
||||
unchecked_map (nano::stats &, bool const & do_delete);
|
||||
~unchecked_map ();
|
||||
|
||||
void put (nano::hash_or_account const & dependency, nano::unchecked_info const & info);
|
||||
|
@ -56,7 +51,6 @@ private:
|
|||
void query_impl (nano::block_hash const & hash);
|
||||
|
||||
private: // Dependencies
|
||||
nano::store & store;
|
||||
nano::stats & stats;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue