Skip to content

Commit

Permalink
Convert store_iterator_impl to a generic base class and subclass for …
Browse files Browse the repository at this point in the history
…both mdb_iterator and mdb_merge_iterator.
  • Loading branch information
clemahieu committed Aug 16, 2018
1 parent 632fcc2 commit 4ccf490
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 109 deletions.
2 changes: 1 addition & 1 deletion rai/node/testing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void rai::system::generate_send_existing (rai::node & node_a, std::vector<rai::a
rai::account account;
random_pool.GenerateBlock (account.bytes.data (), sizeof (account.bytes));
rai::transaction transaction (node_a.store.environment, nullptr, false);
rai::store_merge_iterator entry (node_a.store.latest_begin (transaction, account));
rai::store_iterator entry (node_a.store.latest_begin (transaction, account));
if (entry == node_a.store.latest_end ())
{
entry = node_a.store.latest_begin (transaction);
Expand Down
8 changes: 4 additions & 4 deletions rai/node/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ bool rai::wallet_store::exists (MDB_txn * transaction_a, rai::public_key const &
void rai::wallet_store::serialize_json (MDB_txn * transaction_a, std::string & string_a)
{
boost::property_tree::ptree tree;
for (rai::store_iterator i (std::make_unique<rai::store_iterator_impl> (transaction_a, handle)), n (nullptr); i != n; ++i)
for (rai::store_iterator i (std::make_unique<rai::mdb_iterator> (transaction_a, handle)), n (nullptr); i != n; ++i)
{
tree.put (rai::uint256_union (i->first).to_string (), rai::wallet_value (i->second).key.to_string ());
}
Expand Down Expand Up @@ -1222,7 +1222,7 @@ thread ([this]() { do_wallet_actions (); })
assert (status == 0);
std::string beginning (rai::uint256_union (0).to_string ());
std::string end ((rai::uint256_union (rai::uint256_t (0) - rai::uint256_t (1))).to_string ());
for (rai::store_iterator i (std::make_unique<rai::store_iterator_impl> (transaction, handle, rai::mdb_val (beginning.size (), const_cast<char *> (beginning.c_str ())))), n (std::make_unique<rai::store_iterator_impl> (transaction, handle, rai::mdb_val (end.size (), const_cast<char *> (end.c_str ())))); i != n; ++i)
for (rai::store_iterator i (std::make_unique<rai::mdb_iterator> (transaction, handle, rai::mdb_val (beginning.size (), const_cast<char *> (beginning.c_str ())))), n (std::make_unique<rai::mdb_iterator> (transaction, handle, rai::mdb_val (end.size (), const_cast<char *> (end.c_str ())))); i != n; ++i)
{
rai::uint256_union id;
std::string text (reinterpret_cast<char const *> (i->first.data ()), i->first.size ());
Expand Down Expand Up @@ -1400,13 +1400,13 @@ rai::uint128_t const rai::wallets::high_priority = std::numeric_limits<rai::uint

rai::store_iterator rai::wallet_store::begin (MDB_txn * transaction_a)
{
rai::store_iterator result (std::make_unique<rai::store_iterator_impl> (transaction_a, handle, rai::mdb_val (rai::uint256_union (special_count))));
rai::store_iterator result (std::make_unique<rai::mdb_iterator> (transaction_a, handle, rai::mdb_val (rai::uint256_union (special_count))));
return result;
}

rai::store_iterator rai::wallet_store::begin (MDB_txn * transaction_a, rai::uint256_union const & key)
{
rai::store_iterator result (std::make_unique<rai::store_iterator_impl> (transaction_a, handle, rai::mdb_val (key)));
rai::store_iterator result (std::make_unique<rai::mdb_iterator> (transaction_a, handle, rai::mdb_val (key)));
return result;
}

Expand Down
Loading

0 comments on commit 4ccf490

Please sign in to comment.