diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-08-03 16:07:59 +0200 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-08-05 10:45:19 +0200 |
commit | d8f1222ac50f089a0af29eaf8ce0555bad8366ef (patch) | |
tree | a1658f75bd4d7ffc6655e15ce99767a592fd04d4 /src | |
parent | be8f159ac59b9e700cbd3314ed71ebf39bd5b67a (diff) | |
download | bitcoin-d8f1222ac50f089a0af29eaf8ce0555bad8366ef.tar.xz |
refactor: Correct dbwrapper key naming
The ss- prefix should connotate a DataStream variable. Now that these
variables are byte spans, drop the prefix.
Diffstat (limited to 'src')
-rw-r--r-- | src/dbwrapper.cpp | 26 | ||||
-rw-r--r-- | src/dbwrapper.h | 12 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index b8ee852bb5..847d40eefa 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -168,9 +168,9 @@ void CDBBatch::Clear() 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)); leveldb::Slice slValue(CharCast(ssValue.data()), ssValue.size()); 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(); } -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); // LevelDB serializes erases as: // - byte: header @@ -336,9 +336,9 @@ std::vector<unsigned char> CDBWrapper::CreateObfuscateKey() const 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; leveldb::Status status = DBContext().pdb->Get(DBContext().readoptions, slKey, &strValue); if (!status.ok()) { @@ -350,9 +350,9 @@ std::optional<std::string> CDBWrapper::ReadImpl(Span<const std::byte> ssKey) con 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; 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; } -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 slKey2(CharCast(ssKey2.data()), ssKey2.size()); + leveldb::Slice slKey1(CharCast(key1.data()), key1.size()); + leveldb::Slice slKey2(CharCast(key2.data()), key2.size()); uint64_t size = 0; leveldb::Range range(slKey1, slKey2); 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))}; } -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); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 66170b5efa..eac9594aa1 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -85,8 +85,8 @@ private: size_t size_estimate{0}; - void WriteImpl(Span<const std::byte> ssKey, CDataStream& ssValue); - void EraseImpl(Span<const std::byte> ssKey); + void WriteImpl(Span<const std::byte> key, CDataStream& ssValue); + void EraseImpl(Span<const std::byte> key); public: /** @@ -129,7 +129,7 @@ private: const CDBWrapper &parent; 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> GetValueImpl() const; @@ -206,9 +206,9 @@ private: //! whether or not the database resides in memory bool m_is_memory; - std::optional<std::string> ReadImpl(Span<const std::byte> ssKey) const; - bool ExistsImpl(Span<const std::byte> ssKey) const; - size_t EstimateSizeImpl(Span<const std::byte> ssKey1, Span<const std::byte> ssKey2) const; + std::optional<std::string> ReadImpl(Span<const std::byte> key) const; + bool ExistsImpl(Span<const std::byte> key) const; + size_t EstimateSizeImpl(Span<const std::byte> key1, Span<const std::byte> key2) const; auto& DBContext() const LIFETIMEBOUND { return *Assert(m_db_context); } public: |