0
0
Fork 0
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:
TheCharlatan 2023-07-28 22:53:50 +02:00
parent ea8135de7e
commit d7437908cd
No known key found for this signature in database
GPG key ID: 9B79B45691DB4173
2 changed files with 9 additions and 2 deletions

View file

@ -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(); }

View file

@ -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();