mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
refactor: Split dbwrapper CDBIterator::GetKey implementation
Keep the generic serialization in the header, while moving leveldb-specifics to the implementation file. The context of this commit is an effort to decouple the dbwrapper header file from leveldb includes. To this end, the includes are moved to the dbwrapper implementation file. This is done as part of the kernel project to reduce the number of required includes for users of the kernel.
This commit is contained in:
parent
d7437908cd
commit
b7a1ab5cb4
2 changed files with 7 additions and 2 deletions
|
@ -312,6 +312,11 @@ void CDBIterator::SeekImpl(Span<const std::byte> ssKey)
|
|||
piter->Seek(slKey);
|
||||
}
|
||||
|
||||
Span<const std::byte> CDBIterator::GetKeyImpl() const
|
||||
{
|
||||
return MakeByteSpan(piter->key());
|
||||
}
|
||||
|
||||
CDBIterator::~CDBIterator() { delete piter; }
|
||||
bool CDBIterator::Valid() const { return piter->Valid(); }
|
||||
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }
|
||||
|
|
|
@ -141,6 +141,7 @@ private:
|
|||
leveldb::Iterator *piter;
|
||||
|
||||
void SeekImpl(Span<const std::byte> ssKey);
|
||||
Span<const std::byte> GetKeyImpl() const;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -166,9 +167,8 @@ public:
|
|||
void Next();
|
||||
|
||||
template<typename K> bool GetKey(K& key) {
|
||||
leveldb::Slice slKey = piter->key();
|
||||
try {
|
||||
DataStream ssKey{MakeByteSpan(slKey)};
|
||||
DataStream ssKey{GetKeyImpl()};
|
||||
ssKey >> key;
|
||||
} catch (const std::exception&) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue