mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
refactor: Split dbwrapper CDBIterator::Seek 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
ea8135de7e
commit
d7437908cd
2 changed files with 9 additions and 2 deletions
|
@ -306,6 +306,12 @@ bool CDBWrapper::IsEmpty()
|
|||
return !(it->Valid());
|
||||
}
|
||||
|
||||
void CDBIterator::SeekImpl(Span<const std::byte> ssKey)
|
||||
{
|
||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
||||
piter->Seek(slKey);
|
||||
}
|
||||
|
||||
CDBIterator::~CDBIterator() { delete piter; }
|
||||
bool CDBIterator::Valid() const { return piter->Valid(); }
|
||||
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }
|
||||
|
|
|
@ -140,6 +140,8 @@ private:
|
|||
const CDBWrapper &parent;
|
||||
leveldb::Iterator *piter;
|
||||
|
||||
void SeekImpl(Span<const std::byte> ssKey);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -158,8 +160,7 @@ public:
|
|||
DataStream ssKey{};
|
||||
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey << key;
|
||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
||||
piter->Seek(slKey);
|
||||
SeekImpl(ssKey);
|
||||
}
|
||||
|
||||
void Next();
|
||||
|
|
Loading…
Add table
Reference in a new issue