diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-07-13 21:46:25 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-08-05 10:27:53 +0200 |
commit | b9870c920dc475ec759eaf7339ea42aecba92138 (patch) | |
tree | 764decc38fda125d083a3787311a877def5faf82 /src/dbwrapper.h | |
parent | 532ee812a499e13b123af6b8415d8de1f3804f0f (diff) |
refactor: Split dbwrapper CDBatch::Erase 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/dbwrapper.h')
-rw-r--r-- | src/dbwrapper.h | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 81c75f651e..61f5003db7 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -98,6 +98,7 @@ private: size_t size_estimate{0}; void WriteImpl(Span<const std::byte> ssKey, CDataStream& ssValue); + void EraseImpl(Span<const std::byte> ssKey); public: /** @@ -128,15 +129,7 @@ public: { ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE); ssKey << key; - leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size()); - - batch.Delete(slKey); - // LevelDB serializes erases as: - // - byte: header - // - varint: key length - // - byte[]: key - // The formula below assumes the key is less than 16kB. - size_estimate += 2 + (slKey.size() > 127) + slKey.size(); + EraseImpl(ssKey); ssKey.clear(); } |