Remove the unchecked_store from the store classes
Kept the lmdb::unchecked_store because it contains the LMDB file handler that will be used by the database upgrade code (to be added).
This commit is contained in:
parent
f5ec339a10
commit
2500dfb902
12 changed files with 15 additions and 252 deletions
|
@ -2436,6 +2436,7 @@ namespace nano
|
|||
{
|
||||
// This thest ensures the tombstone_count is increased when there is a delete. The tombstone_count is part of a flush
|
||||
// logic bound to the way RocksDB is used by the node.
|
||||
/* The unchecked table was deprecated and it is being removed, rewrite this test using another table
|
||||
TEST (rocksdb_block_store, tombstone_count)
|
||||
{
|
||||
if (!nano::rocksdb_config::using_rocksdb_in_tests ())
|
||||
|
@ -2469,6 +2470,7 @@ TEST (rocksdb_block_store, tombstone_count)
|
|||
store->unchecked.del (store->tx_begin_write (), nano::unchecked_key (previous, block->hash ()));
|
||||
ASSERT_TIMELY (5s, store->tombstone_map.at (nano::tables::unchecked).num_since_last_flush.load () == 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
namespace nano
|
||||
|
|
|
@ -137,7 +137,6 @@ add_library(
|
|||
lmdb/version_store.hpp
|
||||
lmdb/version_store.cpp
|
||||
lmdb/unchecked_store.hpp
|
||||
lmdb/unchecked_store.cpp
|
||||
lmdb/lmdb.hpp
|
||||
lmdb/lmdb.cpp
|
||||
lmdb/lmdb_env.hpp
|
||||
|
@ -197,8 +196,6 @@ add_library(
|
|||
rocksdb/pending_store.cpp
|
||||
rocksdb/pruned_store.hpp
|
||||
rocksdb/pruned_store.cpp
|
||||
rocksdb/unchecked_store.hpp
|
||||
rocksdb/unchecked_store.cpp
|
||||
rocksdb/version_store.hpp
|
||||
rocksdb/version_store.cpp
|
||||
rocksdb/rocksdb.hpp
|
||||
|
|
|
@ -222,7 +222,7 @@ auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock
|
|||
{
|
||||
std::deque<processed_t> processed;
|
||||
auto scoped_write_guard = write_database_queue.wait (nano::writer::process_batch);
|
||||
auto transaction (node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending, tables::unchecked }));
|
||||
auto transaction (node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending }));
|
||||
nano::timer<std::chrono::milliseconds> timer_l;
|
||||
lock_a.lock ();
|
||||
timer_l.start ();
|
||||
|
|
|
@ -45,7 +45,6 @@ nano::lmdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path co
|
|||
frontier_store,
|
||||
account_store,
|
||||
pending_store,
|
||||
unchecked_store,
|
||||
online_weight_store,
|
||||
pruned_store,
|
||||
peer_store,
|
||||
|
@ -63,7 +62,7 @@ nano::lmdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path co
|
|||
peer_store{ *this },
|
||||
confirmation_height_store{ *this },
|
||||
final_vote_store{ *this },
|
||||
unchecked_store{ *this },
|
||||
unchecked_store{},
|
||||
version_store{ *this },
|
||||
logger (logger_a),
|
||||
env (error, path_a, nano::mdb_env::options::make ().set_config (lmdb_config_a).set_use_no_mem_init (true)),
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#include <nano/node/lmdb/lmdb.hpp>
|
||||
#include <nano/node/lmdb/unchecked_store.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::lmdb::unchecked_store::unchecked_store (nano::lmdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::lmdb::unchecked_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::unchecked);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::unchecked_store::put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info)
|
||||
{
|
||||
auto status = store.put (transaction_a, tables::unchecked, nano::unchecked_key{ dependency, info.block->hash () }, info);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::lmdb::unchecked_store::exists (nano::transaction const & transaction_a, nano::unchecked_key const & key)
|
||||
{
|
||||
nano::mdb_val value;
|
||||
auto status = store.get (transaction_a, tables::unchecked, key, value);
|
||||
release_assert (store.success (status) || store.not_found (status));
|
||||
return store.success (status);
|
||||
}
|
||||
|
||||
void nano::lmdb::unchecked_store::del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a)
|
||||
{
|
||||
auto status (store.del (transaction_a, tables::unchecked, key_a));
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::lmdb::unchecked_store::end () const
|
||||
{
|
||||
return nano::store_iterator<nano::unchecked_key, nano::unchecked_info> (nullptr);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::lmdb::unchecked_store::begin (nano::transaction const & transaction) const
|
||||
{
|
||||
return store.make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction, tables::unchecked);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::lmdb::unchecked_store::lower_bound (nano::transaction const & transaction, nano::unchecked_key const & key) const
|
||||
{
|
||||
return store.make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction, tables::unchecked, key);
|
||||
}
|
||||
|
||||
size_t nano::lmdb::unchecked_store::count (nano::transaction const & transaction_a)
|
||||
{
|
||||
return store.count (transaction_a, tables::unchecked);
|
||||
}
|
|
@ -1,36 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/secure/store.hpp>
|
||||
|
||||
#include <lmdb/libraries/liblmdb/lmdb.h>
|
||||
|
||||
namespace nano
|
||||
namespace nano::lmdb
|
||||
{
|
||||
namespace lmdb
|
||||
class unchecked_store
|
||||
{
|
||||
class store;
|
||||
class unchecked_store : public nano::unchecked_store
|
||||
{
|
||||
private:
|
||||
nano::lmdb::store & store;
|
||||
|
||||
public:
|
||||
unchecked_store (nano::lmdb::store & store_a);
|
||||
|
||||
void clear (nano::write_transaction const & transaction_a) override;
|
||||
void put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::unchecked_key const & unchecked_key_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a) override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> end () const override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> begin (nano::transaction const & transaction_a) const override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> lower_bound (nano::transaction const & transaction_a, nano::unchecked_key const & key_a) const override;
|
||||
size_t count (nano::transaction const & transaction_a) override;
|
||||
|
||||
/**
|
||||
* Unchecked bootstrap blocks info.
|
||||
* nano::block_hash -> nano::unchecked_info
|
||||
*/
|
||||
MDB_dbi unchecked_handle{ 0 };
|
||||
};
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* Unchecked bootstrap blocks info.
|
||||
* nano::block_hash -> nano::unchecked_info
|
||||
*/
|
||||
MDB_dbi unchecked_handle{ 0 };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ nano::rocksdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path
|
|||
frontier_store,
|
||||
account_store,
|
||||
pending_store,
|
||||
unchecked_store,
|
||||
online_weight_store,
|
||||
pruned_store,
|
||||
peer_store,
|
||||
|
@ -80,7 +79,6 @@ nano::rocksdb::store::store (nano::logger_mt & logger_a, boost::filesystem::path
|
|||
frontier_store{ *this },
|
||||
account_store{ *this },
|
||||
pending_store{ *this },
|
||||
unchecked_store{ *this },
|
||||
online_weight_store{ *this },
|
||||
pruned_store{ *this },
|
||||
peer_store{ *this },
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <nano/node/rocksdb/pending_store.hpp>
|
||||
#include <nano/node/rocksdb/pruned_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb_iterator.hpp>
|
||||
#include <nano/node/rocksdb/unchecked_store.hpp>
|
||||
#include <nano/node/rocksdb/version_store.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
|
||||
|
@ -33,8 +32,8 @@ class rocksdb_block_store_tombstone_count_Test;
|
|||
namespace rocksdb
|
||||
{
|
||||
/**
|
||||
* rocksdb implementation of the block store
|
||||
*/
|
||||
* rocksdb implementation of the block store
|
||||
*/
|
||||
class store : public nano::store
|
||||
{
|
||||
private:
|
||||
|
@ -47,7 +46,6 @@ namespace rocksdb
|
|||
nano::rocksdb::peer_store peer_store;
|
||||
nano::rocksdb::pending_store pending_store;
|
||||
nano::rocksdb::pruned_store pruned_store;
|
||||
nano::rocksdb::unchecked_store unchecked_store;
|
||||
nano::rocksdb::version_store version_store;
|
||||
|
||||
public:
|
||||
|
@ -60,7 +58,6 @@ namespace rocksdb
|
|||
friend class nano::rocksdb::peer_store;
|
||||
friend class nano::rocksdb::pending_store;
|
||||
friend class nano::rocksdb::pruned_store;
|
||||
friend class nano::rocksdb::unchecked_store;
|
||||
friend class nano::rocksdb::version_store;
|
||||
|
||||
explicit store (nano::logger_mt &, boost::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false);
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#include <nano/node/lmdb/unchecked_store.hpp>
|
||||
#include <nano/node/rocksdb/rocksdb.hpp>
|
||||
#include <nano/secure/parallel_traversal.hpp>
|
||||
|
||||
nano::rocksdb::unchecked_store::unchecked_store (nano::rocksdb::store & store_a) :
|
||||
store (store_a){};
|
||||
|
||||
void nano::rocksdb::unchecked_store::clear (nano::write_transaction const & transaction_a)
|
||||
{
|
||||
auto status = store.drop (transaction_a, tables::unchecked);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::unchecked_store::put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info)
|
||||
{
|
||||
auto status = store.put (transaction_a, tables::unchecked, nano::unchecked_key{ dependency, info.block->hash () }, info);
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
bool nano::rocksdb::unchecked_store::exists (nano::transaction const & transaction_a, nano::unchecked_key const & key)
|
||||
{
|
||||
nano::rocksdb_val value;
|
||||
auto status = store.get (transaction_a, tables::unchecked, key, value);
|
||||
release_assert (store.success (status) || store.not_found (status));
|
||||
return store.success (status);
|
||||
}
|
||||
|
||||
void nano::rocksdb::unchecked_store::del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a)
|
||||
{
|
||||
auto status (store.del (transaction_a, tables::unchecked, key_a));
|
||||
store.release_assert_success (status);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::rocksdb::unchecked_store::end () const
|
||||
{
|
||||
return nano::store_iterator<nano::unchecked_key, nano::unchecked_info> (nullptr);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::rocksdb::unchecked_store::begin (nano::transaction const & transaction) const
|
||||
{
|
||||
return store.make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction, tables::unchecked);
|
||||
}
|
||||
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> nano::rocksdb::unchecked_store::lower_bound (nano::transaction const & transaction, nano::unchecked_key const & key) const
|
||||
{
|
||||
return store.make_iterator<nano::unchecked_key, nano::unchecked_info> (transaction, tables::unchecked, key);
|
||||
}
|
||||
|
||||
size_t nano::rocksdb::unchecked_store::count (nano::transaction const & transaction_a)
|
||||
{
|
||||
return store.count (transaction_a, tables::unchecked);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/secure/store.hpp>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
namespace rocksdb
|
||||
{
|
||||
class store;
|
||||
class unchecked_store : public nano::unchecked_store
|
||||
{
|
||||
private:
|
||||
nano::rocksdb::store & store;
|
||||
|
||||
public:
|
||||
unchecked_store (nano::rocksdb::store & store_a);
|
||||
|
||||
void clear (nano::write_transaction const & transaction_a) override;
|
||||
void put (nano::write_transaction const & transaction_a, nano::hash_or_account const & dependency, nano::unchecked_info const & info_a) override;
|
||||
bool exists (nano::transaction const & transaction_a, nano::unchecked_key const & unchecked_key_a) override;
|
||||
void del (nano::write_transaction const & transaction_a, nano::unchecked_key const & key_a) override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> end () const override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> begin (nano::transaction const & transaction_a) const override;
|
||||
nano::store_iterator<nano::unchecked_key, nano::unchecked_info> lower_bound (nano::transaction const & transaction_a, nano::unchecked_key const & key_a) const override;
|
||||
size_t count (nano::transaction const & transaction_a) override;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -112,7 +112,6 @@ nano::store::store (
|
|||
nano::frontier_store & frontier_store_a,
|
||||
nano::account_store & account_store_a,
|
||||
nano::pending_store & pending_store_a,
|
||||
nano::unchecked_store & unchecked_store_a,
|
||||
nano::online_weight_store & online_weight_store_a,
|
||||
nano::pruned_store & pruned_store_a,
|
||||
nano::peer_store & peer_store_a,
|
||||
|
@ -124,7 +123,6 @@ nano::store::store (
|
|||
frontier (frontier_store_a),
|
||||
account (account_store_a),
|
||||
pending (pending_store_a),
|
||||
unchecked (unchecked_store_a),
|
||||
online_weight (online_weight_store_a),
|
||||
pruned (pruned_store_a),
|
||||
peer (peer_store_a),
|
||||
|
@ -155,20 +153,6 @@ void nano::store::initialize (nano::write_transaction const & transaction_a, nan
|
|||
frontier.put (transaction_a, hash_l, constants.genesis->account ());
|
||||
}
|
||||
|
||||
auto nano::unchecked_store::equal_range (nano::transaction const & transaction, nano::block_hash const & dependency) -> std::pair<iterator, iterator>
|
||||
{
|
||||
nano::unchecked_key begin_l{ dependency, 0 };
|
||||
nano::unchecked_key end_l{ nano::block_hash{ dependency.number () + 1 }, 0 };
|
||||
// Adjust for edge case where number () + 1 wraps around.
|
||||
auto end_iter = begin_l.previous < end_l.previous ? lower_bound (transaction, end_l) : end ();
|
||||
return std::make_pair (lower_bound (transaction, begin_l), std::move (end_iter));
|
||||
}
|
||||
|
||||
auto nano::unchecked_store::full_range (nano::transaction const & transaction) -> std::pair<iterator, iterator>
|
||||
{
|
||||
return std::make_pair (begin (transaction), end ());
|
||||
}
|
||||
|
||||
std::optional<nano::account_info> nano::account_store::get (const nano::transaction & transaction, const nano::account & account)
|
||||
{
|
||||
nano::account_info info;
|
||||
|
|
|
@ -103,22 +103,6 @@ public:
|
|||
static_assert (std::is_standard_layout<nano::pending_key>::value, "Standard layout is required");
|
||||
}
|
||||
|
||||
db_val (nano::unchecked_info const & val_a) :
|
||||
buffer (std::make_shared<std::vector<uint8_t>> ())
|
||||
{
|
||||
{
|
||||
nano::vectorstream stream (*buffer);
|
||||
val_a.serialize (stream);
|
||||
}
|
||||
convert_buffer_to_value ();
|
||||
}
|
||||
|
||||
db_val (nano::unchecked_key const & val_a) :
|
||||
db_val (sizeof (val_a), const_cast<nano::unchecked_key *> (&val_a))
|
||||
{
|
||||
static_assert (std::is_standard_layout<nano::unchecked_key>::value, "Standard layout is required");
|
||||
}
|
||||
|
||||
db_val (nano::confirmation_height_info const & val_a) :
|
||||
buffer (std::make_shared<std::vector<uint8_t>> ())
|
||||
{
|
||||
|
@ -222,25 +206,6 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
explicit operator nano::unchecked_info () const
|
||||
{
|
||||
nano::bufferstream stream (reinterpret_cast<uint8_t const *> (data ()), size ());
|
||||
nano::unchecked_info result;
|
||||
bool error (result.deserialize (stream));
|
||||
(void)error;
|
||||
debug_assert (!error);
|
||||
return result;
|
||||
}
|
||||
|
||||
explicit operator nano::unchecked_key () const
|
||||
{
|
||||
nano::unchecked_key result;
|
||||
debug_assert (size () == sizeof (result));
|
||||
static_assert (sizeof (nano::unchecked_key::previous) + sizeof (nano::pending_key::hash) == sizeof (result), "Packed class");
|
||||
std::copy (reinterpret_cast<uint8_t const *> (data ()), reinterpret_cast<uint8_t const *> (data ()) + sizeof (result), reinterpret_cast<uint8_t *> (&result));
|
||||
return result;
|
||||
}
|
||||
|
||||
explicit operator nano::uint128_union () const
|
||||
{
|
||||
return convert<nano::uint128_union> ();
|
||||
|
@ -745,26 +710,6 @@ public:
|
|||
virtual void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::account, nano::confirmation_height_info>, nano::store_iterator<nano::account, nano::confirmation_height_info>)> const &) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages unchecked storage and iteration
|
||||
*/
|
||||
class unchecked_store
|
||||
{
|
||||
public:
|
||||
using iterator = nano::store_iterator<nano::unchecked_key, nano::unchecked_info>;
|
||||
|
||||
virtual void clear (nano::write_transaction const &) = 0;
|
||||
virtual void put (nano::write_transaction const &, nano::hash_or_account const & dependency, nano::unchecked_info const &) = 0;
|
||||
std::pair<iterator, iterator> equal_range (nano::transaction const & transaction, nano::block_hash const & dependency);
|
||||
std::pair<iterator, iterator> full_range (nano::transaction const & transaction);
|
||||
virtual bool exists (nano::transaction const & transaction_a, nano::unchecked_key const & unchecked_key_a) = 0;
|
||||
virtual void del (nano::write_transaction const &, nano::unchecked_key const &) = 0;
|
||||
virtual iterator begin (nano::transaction const &) const = 0;
|
||||
virtual iterator lower_bound (nano::transaction const &, nano::unchecked_key const &) const = 0;
|
||||
virtual iterator end () const = 0;
|
||||
virtual size_t count (nano::transaction const &) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages final vote storage and iteration
|
||||
*/
|
||||
|
@ -821,7 +766,6 @@ public:
|
|||
virtual uint64_t account_height (nano::transaction const & transaction_a, nano::block_hash const & hash_a) const = 0;
|
||||
};
|
||||
|
||||
class unchecked_map;
|
||||
/**
|
||||
* Store manager
|
||||
*/
|
||||
|
@ -836,7 +780,6 @@ public:
|
|||
nano::frontier_store &,
|
||||
nano::account_store &,
|
||||
nano::pending_store &,
|
||||
nano::unchecked_store &,
|
||||
nano::online_weight_store &,
|
||||
nano::pruned_store &,
|
||||
nano::peer_store &,
|
||||
|
@ -861,9 +804,6 @@ public:
|
|||
static int constexpr version_minimum{ 14 };
|
||||
static int constexpr version_current{ 21 };
|
||||
|
||||
private:
|
||||
unchecked_store & unchecked;
|
||||
|
||||
public:
|
||||
online_weight_store & online_weight;
|
||||
pruned_store & pruned;
|
||||
|
@ -890,8 +830,6 @@ public:
|
|||
virtual nano::read_transaction tx_begin_read () const = 0;
|
||||
|
||||
virtual std::string vendor_get () const = 0;
|
||||
|
||||
friend class unchecked_map;
|
||||
};
|
||||
|
||||
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 = false, 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue