dbwrapper: Use DataStream for batch operations

This commit is contained in:
TheCharlatan 2023-09-09 13:30:50 +02:00 committed by MarcoFalke
parent fd69ffbbfb
commit 5c2b3cd4b8
2 changed files with 6 additions and 7 deletions

View file

@ -4,7 +4,6 @@
#include <dbwrapper.h> #include <dbwrapper.h>
#include <clientversion.h>
#include <logging.h> #include <logging.h>
#include <random.h> #include <random.h>
#include <serialize.h> #include <serialize.h>
@ -156,9 +155,9 @@ struct CDBBatch::WriteBatchImpl {
leveldb::WriteBatch batch; leveldb::WriteBatch batch;
}; };
CDBBatch::CDBBatch(const CDBWrapper& _parent) : parent(_parent), CDBBatch::CDBBatch(const CDBWrapper& _parent)
m_impl_batch{std::make_unique<CDBBatch::WriteBatchImpl>()}, : parent{_parent},
ssValue(SER_DISK, CLIENT_VERSION){}; m_impl_batch{std::make_unique<CDBBatch::WriteBatchImpl>()} {};
CDBBatch::~CDBBatch() = default; CDBBatch::~CDBBatch() = default;
@ -168,7 +167,7 @@ void CDBBatch::Clear()
size_estimate = 0; size_estimate = 0;
} }
void CDBBatch::WriteImpl(Span<const std::byte> key, CDataStream& ssValue) void CDBBatch::WriteImpl(Span<const std::byte> key, DataStream& ssValue)
{ {
leveldb::Slice slKey(CharCast(key.data()), key.size()); leveldb::Slice slKey(CharCast(key.data()), key.size());
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent)); ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));

View file

@ -80,11 +80,11 @@ private:
const std::unique_ptr<WriteBatchImpl> m_impl_batch; const std::unique_ptr<WriteBatchImpl> m_impl_batch;
DataStream ssKey{}; DataStream ssKey{};
CDataStream ssValue; DataStream ssValue{};
size_t size_estimate{0}; size_t size_estimate{0};
void WriteImpl(Span<const std::byte> key, CDataStream& ssValue); void WriteImpl(Span<const std::byte> key, DataStream& ssValue);
void EraseImpl(Span<const std::byte> key); void EraseImpl(Span<const std::byte> key);
public: public: