Remove store_entry class since it's effectively just a pair of rai::mdb_val
This commit is contained in:
parent
537aa6bc36
commit
d1193ab407
2 changed files with 16 additions and 39 deletions
|
@ -54,26 +54,9 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
rai::store_entry::store_entry () :
|
||||
first (0, nullptr),
|
||||
second (0, nullptr)
|
||||
std::pair<rai::mdb_val, rai::mdb_val> * rai::store_iterator::operator-> ()
|
||||
{
|
||||
}
|
||||
|
||||
void rai::store_entry::clear ()
|
||||
{
|
||||
first = { 0, nullptr };
|
||||
second = { 0, nullptr };
|
||||
}
|
||||
|
||||
rai::store_entry * rai::store_entry::operator-> ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
rai::store_entry & rai::store_iterator::operator-> ()
|
||||
{
|
||||
return current;
|
||||
return ¤t;
|
||||
}
|
||||
|
||||
rai::store_iterator::store_iterator (MDB_txn * transaction_a, MDB_dbi db_a) :
|
||||
|
@ -90,7 +73,7 @@ cursor (nullptr)
|
|||
}
|
||||
else
|
||||
{
|
||||
current.clear ();
|
||||
clear ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +97,7 @@ cursor (nullptr)
|
|||
}
|
||||
else
|
||||
{
|
||||
current.clear ();
|
||||
clear ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +122,7 @@ rai::store_iterator & rai::store_iterator::operator++ ()
|
|||
auto status (mdb_cursor_get (cursor, ¤t.first.value, ¤t.second.value, MDB_NEXT));
|
||||
if (status == MDB_NOTFOUND)
|
||||
{
|
||||
current.clear ();
|
||||
clear ();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -150,7 +133,7 @@ void rai::store_iterator::next_dup ()
|
|||
auto status (mdb_cursor_get (cursor, ¤t.first.value, ¤t.second.value, MDB_NEXT_DUP));
|
||||
if (status == MDB_NOTFOUND)
|
||||
{
|
||||
current.clear ();
|
||||
clear ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +146,7 @@ rai::store_iterator & rai::store_iterator::operator= (rai::store_iterator && oth
|
|||
cursor = other_a.cursor;
|
||||
other_a.cursor = nullptr;
|
||||
current = other_a.current;
|
||||
other_a.current.clear ();
|
||||
other_a.clear ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -181,6 +164,12 @@ bool rai::store_iterator::operator!= (rai::store_iterator const & other_a) const
|
|||
return !(*this == other_a);
|
||||
}
|
||||
|
||||
void rai::store_iterator::clear ()
|
||||
{
|
||||
current.first = rai::mdb_val ();
|
||||
current.second = rai::mdb_val ();
|
||||
}
|
||||
|
||||
rai::store_iterator rai::block_store::block_info_begin (MDB_txn * transaction_a, rai::block_hash const & hash_a)
|
||||
{
|
||||
rai::store_iterator result (transaction_a, blocks_info, rai::mdb_val (hash_a));
|
||||
|
|
|
@ -4,19 +4,6 @@
|
|||
|
||||
namespace rai
|
||||
{
|
||||
/**
|
||||
* The value produced when iterating with \ref store_iterator
|
||||
*/
|
||||
class store_entry
|
||||
{
|
||||
public:
|
||||
store_entry ();
|
||||
void clear ();
|
||||
store_entry * operator-> ();
|
||||
rai::mdb_val first;
|
||||
rai::mdb_val second;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates the key/value pairs of a transaction
|
||||
*/
|
||||
|
@ -33,11 +20,12 @@ public:
|
|||
void next_dup ();
|
||||
rai::store_iterator & operator= (rai::store_iterator &&);
|
||||
rai::store_iterator & operator= (rai::store_iterator const &) = delete;
|
||||
rai::store_entry & operator-> ();
|
||||
std::pair<rai::mdb_val, rai::mdb_val> * operator-> ();
|
||||
bool operator== (rai::store_iterator const &) const;
|
||||
bool operator!= (rai::store_iterator const &) const;
|
||||
void clear ();
|
||||
MDB_cursor * cursor;
|
||||
rai::store_entry current;
|
||||
std::pair<rai::mdb_val, rai::mdb_val> current;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue