Skip to content

Commit

Permalink
Remove legacy upgrade code from lmdb store.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Sep 25, 2023
1 parent 7a2ff65 commit 41099e5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 77 deletions.
42 changes: 0 additions & 42 deletions nano/store/lmdb/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,6 @@ class block : public nano::store::block
store::iterator<nano::block_hash, nano::store::block_w_sideband> end () const override;
void for_each_par (std::function<void (store::read_transaction const &, store::iterator<nano::block_hash, block_w_sideband>, store::iterator<nano::block_hash, block_w_sideband>)> const & action_a) const override;

/**
* Maps block hash to send block. (Removed)
* nano::block_hash -> nano::send_block
*/
MDB_dbi send_blocks_handle{ 0 };

/**
* Maps block hash to receive block. (Removed)
* nano::block_hash -> nano::receive_block
*/
MDB_dbi receive_blocks_handle{ 0 };

/**
* Maps block hash to open block. (Removed)
* nano::block_hash -> nano::open_block
*/
MDB_dbi open_blocks_handle{ 0 };

/**
* Maps block hash to change block. (Removed)
* nano::block_hash -> nano::change_block
*/
MDB_dbi change_blocks_handle{ 0 };

/**
* Maps block hash to v0 state block. (Removed)
* nano::block_hash -> nano::state_block
*/
MDB_dbi state_blocks_v0_handle{ 0 };

/**
* Maps block hash to v1 state block. (Removed)
* nano::block_hash -> nano::state_block
*/
MDB_dbi state_blocks_v1_handle{ 0 };

/**
* Maps block hash to state block. (Removed)
* nano::block_hash -> nano::state_block
*/
MDB_dbi state_blocks_handle{ 0 };

/**
* Contains block_sideband and block for all block types (legacy send/change/open/receive & state blocks)
* nano::block_hash -> nano::block_sideband, nano::block
Expand Down
36 changes: 1 addition & 35 deletions nano/store/lmdb/lmdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,41 +194,7 @@ void nano::store::lmdb::component::open_databases (bool & error_a, store::transa
error_a |= mdb_dbi_open (env.tx (transaction_a), "pending", flags, &pending_store.pending_v0_handle) != 0;
pending_store.pending_handle = pending_store.pending_v0_handle;
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 < 19)
{
// These legacy (and state) block databases are no longer used, but need opening so they can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "send", flags, &block_store.send_blocks_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "receive", flags, &block_store.receive_blocks_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "open", flags, &block_store.open_blocks_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "change", flags, &block_store.change_blocks_handle) != 0;
if (version_l >= 15)
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "state_blocks", flags, &block_store.state_blocks_handle) != 0;
block_store.state_blocks_v0_handle = block_store.state_blocks_handle;
}
}
else
{
error_a |= mdb_dbi_open (env.tx (transaction_a), "blocks", MDB_CREATE, &block_store.blocks_handle) != 0;
}

if (version_l < 16)
{
// The representation database is no longer used, but needs opening so that it can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "representation", flags, &account_store.representation_handle) != 0;
}

if (version_l < 15)
{
// These databases are no longer used, but need opening so they can be deleted during an upgrade
error_a |= mdb_dbi_open (env.tx (transaction_a), "state", flags, &block_store.state_blocks_v0_handle) != 0;
block_store.state_blocks_handle = block_store.state_blocks_v0_handle;
error_a |= mdb_dbi_open (env.tx (transaction_a), "accounts_v1", flags, &account_store.accounts_v1_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "pending_v1", flags, &pending_store.pending_v1_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "state_v1", flags, &block_store.state_blocks_v1_handle) != 0;
}
error_a |= mdb_dbi_open (env.tx (transaction_a), "blocks", MDB_CREATE, &block_store.blocks_handle) != 0;
}

bool nano::store::lmdb::component::do_upgrades (store::write_transaction & transaction_a, nano::ledger_constants & constants, bool & needs_vacuuming)
Expand Down

0 comments on commit 41099e5

Please sign in to comment.