Skip to content

Commit b7a1ab5

Browse files
committed
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.
1 parent d743790 commit b7a1ab5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/dbwrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ void CDBIterator::SeekImpl(Span<const std::byte> ssKey)
312312
piter->Seek(slKey);
313313
}
314314

315+
Span<const std::byte> CDBIterator::GetKeyImpl() const
316+
{
317+
return MakeByteSpan(piter->key());
318+
}
319+
315320
CDBIterator::~CDBIterator() { delete piter; }
316321
bool CDBIterator::Valid() const { return piter->Valid(); }
317322
void CDBIterator::SeekToFirst() { piter->SeekToFirst(); }

src/dbwrapper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class CDBIterator
141141
leveldb::Iterator *piter;
142142

143143
void SeekImpl(Span<const std::byte> ssKey);
144+
Span<const std::byte> GetKeyImpl() const;
144145

145146
public:
146147

@@ -166,9 +167,8 @@ class CDBIterator
166167
void Next();
167168

168169
template<typename K> bool GetKey(K& key) {
169-
leveldb::Slice slKey = piter->key();
170170
try {
171-
DataStream ssKey{MakeByteSpan(slKey)};
171+
DataStream ssKey{GetKeyImpl()};
172172
ssKey >> key;
173173
} catch (const std::exception&) {
174174
return false;

0 commit comments

Comments
 (0)