Skip to content

Commit

Permalink
Remove nano::wallets::split_if_needed
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Sep 25, 2023
1 parent d0b4932 commit afc0666
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
46 changes: 0 additions & 46 deletions nano/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ nano::wallets::wallets (bool error_a, nano::node & node_a) :
{
auto transaction (tx_begin_write ());
auto status (mdb_dbi_open (env.tx (transaction), nullptr, MDB_CREATE, &handle));
split_if_needed (transaction, node.store);
status |= mdb_dbi_open (env.tx (transaction), "send_action_ids", MDB_CREATE, &send_action_ids);
release_assert (status == 0);
std::string beginning (nano::uint256_union (0).to_string ());
Expand Down Expand Up @@ -1698,51 +1697,6 @@ void nano::wallets::ongoing_compute_reps ()
});
}

void nano::wallets::split_if_needed (store::transaction & transaction_destination, nano::store::component & store_a)
{
auto store_l = dynamic_cast<nano::store::lmdb::component *> (&store_a);
if (store_l != nullptr)
{
if (items.empty ())
{
std::string beginning (nano::uint256_union (0).to_string ());
std::string end ((nano::uint256_union (nano::uint256_t (0) - nano::uint256_t (1))).to_string ());

auto get_store_it = [&handle = handle, &env = env] (store::transaction const & transaction_source, std::string const & hash) {
return store::iterator<std::array<char, 64>, nano::no_value> (std::make_unique<nano::store::lmdb::iterator<std::array<char, 64>, nano::no_value>> (transaction_source, env, handle, nano::store::lmdb::db_val (hash.size (), const_cast<char *> (hash.c_str ()))));
};

// First do a read pass to check if there are any wallets that need extracting (to save holding a write lock and potentially being blocked)
auto wallets_need_splitting (false);
{
auto transaction_source (store_l->tx_begin_read ());
auto i = get_store_it (transaction_source, beginning);
auto n = get_store_it (transaction_source, end);
wallets_need_splitting = (i != n);
}

if (wallets_need_splitting)
{
auto transaction_source (store_l->tx_begin_write ());
auto i = get_store_it (transaction_source, beginning);
auto n = get_store_it (transaction_source, end);
auto tx_source = static_cast<MDB_txn *> (transaction_source.get_handle ());
auto tx_destination = static_cast<MDB_txn *> (transaction_destination.get_handle ());
for (; i != n; ++i)
{
nano::uint256_union id;
std::string text (i->first.data (), i->first.size ());
auto error1 (id.decode_hex (text));
(void)error1;
debug_assert (!error1);
debug_assert (strlen (text.c_str ()) == text.size ());
move_table (text, tx_source, tx_destination);
}
}
}
}
}

void nano::wallets::move_table (std::string const & name_a, MDB_txn * tx_source, MDB_txn * tx_destination)
{
MDB_dbi handle_source;
Expand Down
1 change: 0 additions & 1 deletion nano/node/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ class wallets final
bool check_rep (nano::account const &, nano::uint128_t const &, bool const = true);
void compute_reps ();
void ongoing_compute_reps ();
void split_if_needed (store::transaction &, nano::store::component &);
void move_table (std::string const &, MDB_txn *, MDB_txn *);
std::unordered_map<nano::wallet_id, std::shared_ptr<nano::wallet>> get_wallets ();
nano::network_params & network_params;
Expand Down

0 comments on commit afc0666

Please sign in to comment.