Skip to content

Commit

Permalink
Simplify the unchecked handle and the upgrade code
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Silva committed Apr 25, 2023
1 parent 865c79f commit b9fae83
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
6 changes: 4 additions & 2 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,8 @@ namespace lmdb
nano::lmdb::store store (logger, path, nano::dev::constants);
auto transaction (store.tx_begin_write ());
ASSERT_EQ (store.version.get (transaction), store.version_current);
ASSERT_EQ (MDB_NOTFOUND, mdb_dbi_open (store.env.tx (transaction), "unchecked", 0, &store.block_store.unchecked_handle));
MDB_dbi unchecked_handle{ 0 };
ASSERT_EQ (MDB_NOTFOUND, mdb_dbi_open (store.env.tx (transaction), "unchecked", 0, &unchecked_handle));
};

// Testing current version doesn't contain the unchecked table
Expand All @@ -2204,7 +2205,8 @@ namespace lmdb
nano::lmdb::store store (logger, path, nano::dev::constants);
auto transaction (store.tx_begin_write ());
store.version.put (transaction, 21);
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "unchecked", MDB_CREATE, &store.block_store.unchecked_handle));
MDB_dbi unchecked_handle{ 0 };
ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "unchecked", MDB_CREATE, &unchecked_handle));
ASSERT_EQ (store.version.get (transaction), 21);
}

Expand Down
6 changes: 0 additions & 6 deletions nano/node/lmdb/block_store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ namespace lmdb
*/
MDB_dbi state_blocks_handle{ 0 };

/**
* Unchecked bootstrap blocks info. (Removed)
* nano::block_hash -> nano::unchecked_info
*/
MDB_dbi unchecked_handle{ 0 };

/**
* Meta information about block store, such as versions.
* nano::uint256_union (arbitrary key) -> blob
Expand Down
11 changes: 3 additions & 8 deletions nano/node/lmdb/lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ void nano::lmdb::store::open_databases (bool & error_a, nano::transaction const
error_a |= mdb_dbi_open (env.tx (transaction_a), "final_votes", flags, &final_vote_store.final_votes_handle) != 0;

auto version_l = version.get (transaction_a);
if (version_l < 22)
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "unchecked", flags, &block_store.unchecked_handle) != 0;
}

if (version_l < 19)
{
// These legacy (and state) block databases are no longer used, but need opening so they can be deleted during an upgrade
Expand Down Expand Up @@ -785,7 +780,9 @@ void nano::lmdb::store::upgrade_v20_to_v21 (nano::write_transaction const & tran
void nano::lmdb::store::upgrade_v21_to_v22 (nano::write_transaction const & transaction_a)
{
logger.always_log ("Preparing v21 to v22 database upgrade...");
mdb_drop (env.tx (transaction_a), block_store.unchecked_handle, 1); // del = 1, to delete it from the environment and close the DB handle.
MDB_dbi unchecked_handle{ 0 };
release_assert (!mdb_dbi_open (env.tx (transaction_a), "unchecked", MDB_CREATE, &unchecked_handle));
release_assert (!mdb_drop (env.tx (transaction_a), unchecked_handle, 1)); // del = 1, to delete it from the environment and close the DB handle.
version.put (transaction_a, 22);
logger.always_log ("Finished removing unchecked table");
}
Expand Down Expand Up @@ -879,8 +876,6 @@ MDB_dbi nano::lmdb::store::table_to_dbi (tables table_a) const
return block_store.blocks_handle;
case tables::pending:
return pending_store.pending_handle;
case tables::unchecked:
return block_store.unchecked_handle;
case tables::online_weight:
return online_weight_store.online_weight_handle;
case tables::meta:
Expand Down

0 comments on commit b9fae83

Please sign in to comment.