Skip to content

Commit

Permalink
Remove the unchecked_store from the store classes
Browse files Browse the repository at this point in the history
Kept the lmdb::unchecked_store because it contains the LMDB file handler
that will be used by the database upgrade code (to be added).
  • Loading branch information
Thiago Silva committed Apr 19, 2023
1 parent f5ec339 commit 2500dfb
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 252 deletions.
2 changes: 2 additions & 0 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ())
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
3 changes: 1 addition & 2 deletions nano/node/lmdb/lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)),
Expand Down
52 changes: 0 additions & 52 deletions nano/node/lmdb/unchecked_store.cpp

This file was deleted.

38 changes: 9 additions & 29 deletions nano/node/lmdb/unchecked_store.hpp
Original file line number Diff line number Diff line change
@@ -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 };
};
}
2 changes: 0 additions & 2 deletions nano/node/rocksdb/rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 },
Expand Down
7 changes: 2 additions & 5 deletions nano/node/rocksdb/rocksdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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);
Expand Down
52 changes: 0 additions & 52 deletions nano/node/rocksdb/unchecked_store.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions nano/node/rocksdb/unchecked_store.hpp

This file was deleted.

16 changes: 0 additions & 16 deletions nano/secure/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2500dfb

Please sign in to comment.