mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-01 11:11:15 +02:00
refactor: Correct dbwrapper key naming
The ss- prefix should connotate a DataStream variable. Now that these variables are byte spans, drop the prefix.
This commit is contained in:
@ -168,9 +168,9 @@ void CDBBatch::Clear()
|
|||||||
size_estimate = 0;
|
size_estimate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDBBatch::WriteImpl(Span<const std::byte> ssKey, CDataStream& ssValue)
|
void CDBBatch::WriteImpl(Span<const std::byte> key, CDataStream& ssValue)
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
leveldb::Slice slKey(CharCast(key.data()), key.size());
|
||||||
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
|
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
|
||||||
leveldb::Slice slValue(CharCast(ssValue.data()), ssValue.size());
|
leveldb::Slice slValue(CharCast(ssValue.data()), ssValue.size());
|
||||||
m_impl_batch->batch.Put(slKey, slValue);
|
m_impl_batch->batch.Put(slKey, slValue);
|
||||||
@ -184,9 +184,9 @@ void CDBBatch::WriteImpl(Span<const std::byte> ssKey, CDataStream& ssValue)
|
|||||||
size_estimate += 3 + (slKey.size() > 127) + slKey.size() + (slValue.size() > 127) + slValue.size();
|
size_estimate += 3 + (slKey.size() > 127) + slKey.size() + (slValue.size() > 127) + slValue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDBBatch::EraseImpl(Span<const std::byte> ssKey)
|
void CDBBatch::EraseImpl(Span<const std::byte> key)
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
leveldb::Slice slKey(CharCast(key.data()), key.size());
|
||||||
m_impl_batch->batch.Delete(slKey);
|
m_impl_batch->batch.Delete(slKey);
|
||||||
// LevelDB serializes erases as:
|
// LevelDB serializes erases as:
|
||||||
// - byte: header
|
// - byte: header
|
||||||
@ -336,9 +336,9 @@ std::vector<unsigned char> CDBWrapper::CreateObfuscateKey() const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> CDBWrapper::ReadImpl(Span<const std::byte> ssKey) const
|
std::optional<std::string> CDBWrapper::ReadImpl(Span<const std::byte> key) const
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
leveldb::Slice slKey(CharCast(key.data()), key.size());
|
||||||
std::string strValue;
|
std::string strValue;
|
||||||
leveldb::Status status = DBContext().pdb->Get(DBContext().readoptions, slKey, &strValue);
|
leveldb::Status status = DBContext().pdb->Get(DBContext().readoptions, slKey, &strValue);
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
@ -350,9 +350,9 @@ std::optional<std::string> CDBWrapper::ReadImpl(Span<const std::byte> ssKey) con
|
|||||||
return strValue;
|
return strValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDBWrapper::ExistsImpl(Span<const std::byte> ssKey) const
|
bool CDBWrapper::ExistsImpl(Span<const std::byte> key) const
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
leveldb::Slice slKey(CharCast(key.data()), key.size());
|
||||||
|
|
||||||
std::string strValue;
|
std::string strValue;
|
||||||
leveldb::Status status = DBContext().pdb->Get(DBContext().readoptions, slKey, &strValue);
|
leveldb::Status status = DBContext().pdb->Get(DBContext().readoptions, slKey, &strValue);
|
||||||
@ -365,10 +365,10 @@ bool CDBWrapper::ExistsImpl(Span<const std::byte> ssKey) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CDBWrapper::EstimateSizeImpl(Span<const std::byte> ssKey1, Span<const std::byte> ssKey2) const
|
size_t CDBWrapper::EstimateSizeImpl(Span<const std::byte> key1, Span<const std::byte> key2) const
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey1(CharCast(ssKey1.data()), ssKey1.size());
|
leveldb::Slice slKey1(CharCast(key1.data()), key1.size());
|
||||||
leveldb::Slice slKey2(CharCast(ssKey2.data()), ssKey2.size());
|
leveldb::Slice slKey2(CharCast(key2.data()), key2.size());
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
leveldb::Range range(slKey1, slKey2);
|
leveldb::Range range(slKey1, slKey2);
|
||||||
DBContext().pdb->GetApproximateSizes(&range, 1, &size);
|
DBContext().pdb->GetApproximateSizes(&range, 1, &size);
|
||||||
@ -396,9 +396,9 @@ CDBIterator* CDBWrapper::NewIterator()
|
|||||||
return new CDBIterator{*this, std::make_unique<CDBIterator::IteratorImpl>(DBContext().pdb->NewIterator(DBContext().iteroptions))};
|
return new CDBIterator{*this, std::make_unique<CDBIterator::IteratorImpl>(DBContext().pdb->NewIterator(DBContext().iteroptions))};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDBIterator::SeekImpl(Span<const std::byte> ssKey)
|
void CDBIterator::SeekImpl(Span<const std::byte> key)
|
||||||
{
|
{
|
||||||
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
leveldb::Slice slKey(CharCast(key.data()), key.size());
|
||||||
m_impl_iter->iter->Seek(slKey);
|
m_impl_iter->iter->Seek(slKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ private:
|
|||||||
|
|
||||||
size_t size_estimate{0};
|
size_t size_estimate{0};
|
||||||
|
|
||||||
void WriteImpl(Span<const std::byte> ssKey, CDataStream& ssValue);
|
void WriteImpl(Span<const std::byte> key, CDataStream& ssValue);
|
||||||
void EraseImpl(Span<const std::byte> ssKey);
|
void EraseImpl(Span<const std::byte> key);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -129,7 +129,7 @@ private:
|
|||||||
const CDBWrapper &parent;
|
const CDBWrapper &parent;
|
||||||
const std::unique_ptr<IteratorImpl> m_impl_iter;
|
const std::unique_ptr<IteratorImpl> m_impl_iter;
|
||||||
|
|
||||||
void SeekImpl(Span<const std::byte> ssKey);
|
void SeekImpl(Span<const std::byte> key);
|
||||||
Span<const std::byte> GetKeyImpl() const;
|
Span<const std::byte> GetKeyImpl() const;
|
||||||
Span<const std::byte> GetValueImpl() const;
|
Span<const std::byte> GetValueImpl() const;
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ private:
|
|||||||
//! whether or not the database resides in memory
|
//! whether or not the database resides in memory
|
||||||
bool m_is_memory;
|
bool m_is_memory;
|
||||||
|
|
||||||
std::optional<std::string> ReadImpl(Span<const std::byte> ssKey) const;
|
std::optional<std::string> ReadImpl(Span<const std::byte> key) const;
|
||||||
bool ExistsImpl(Span<const std::byte> ssKey) const;
|
bool ExistsImpl(Span<const std::byte> key) const;
|
||||||
size_t EstimateSizeImpl(Span<const std::byte> ssKey1, Span<const std::byte> ssKey2) const;
|
size_t EstimateSizeImpl(Span<const std::byte> key1, Span<const std::byte> key2) const;
|
||||||
auto& DBContext() const LIFETIMEBOUND { return *Assert(m_db_context); }
|
auto& DBContext() const LIFETIMEBOUND { return *Assert(m_db_context); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user