diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index b3faff10cea..f4935c4f357 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -158,14 +158,18 @@ struct CDBBatch::WriteBatchImpl { CDBBatch::CDBBatch(const CDBWrapper& _parent) : parent{_parent}, - m_impl_batch{std::make_unique()} {}; + m_impl_batch{std::make_unique()} +{ + Clear(); +}; CDBBatch::~CDBBatch() = default; void CDBBatch::Clear() { m_impl_batch->batch.Clear(); - size_estimate = 0; + assert(m_impl_batch->batch.ApproximateSize() == kHeader); + size_estimate = kHeader; // TODO remove } void CDBBatch::WriteImpl(std::span key, DataStream& ssValue) diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 98446361e4e..1ff7dc1d2ee 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -75,6 +75,8 @@ class CDBBatch friend class CDBWrapper; private: + static constexpr size_t kHeader{12}; // See: src/leveldb/db/write_batch.cc#L27 + const CDBWrapper &parent; struct WriteBatchImpl;