diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-07-28 22:53:50 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-08-05 10:42:45 +0200 |
commit | d7437908cdf242626263ba9d5541addcddadc594 (patch) | |
tree | d3b8b3d6cfd3f1b195e26043b7c1f0777ae12a48 /src | |
parent | ea8135de7e617259cda3fc7b1c8e7569d454fd57 (diff) | |
download | bitcoin-d7437908cdf242626263ba9d5541addcddadc594.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/dbwrapper.cpp | 6 | ||||
-rw-r--r-- | src/dbwrapper.h | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index ff2bc8b4e8..87d46f3192 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -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(); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 9016111209..aa2b31b160 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -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(); |