mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Coins: Add kHeader
to CDBBatch::size_estimate
The initialization of the manual `size_estimate` in `CDBBatch::Clear()` is corrected from `0` to `kHeader` (LevelDB's fixed batch header size). This aligns the manual estimate with LevelDB's actual size immediately after clearing, fixing discrepancies that would otherwise be caught by tests in the next commit (e.g., `coins_tests`, `validation_chainstatemanager_tests`).
This commit is contained in:
parent
0dc74c92c0
commit
751077c6e2
2 changed files with 8 additions and 2 deletions
|
@ -158,14 +158,18 @@ struct CDBBatch::WriteBatchImpl {
|
|||
|
||||
CDBBatch::CDBBatch(const CDBWrapper& _parent)
|
||||
: parent{_parent},
|
||||
m_impl_batch{std::make_unique<CDBBatch::WriteBatchImpl>()} {};
|
||||
m_impl_batch{std::make_unique<CDBBatch::WriteBatchImpl>()}
|
||||
{
|
||||
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<const std::byte> key, DataStream& ssValue)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue