![]() |
Bitcoin Core 32.1.0
P2P Digital Currency
|
#include <dbwrapper.h>
Classes | |
| struct | ReadFailure |
Public Types | |
| using | ReadStatus = util::Expected<bool, ReadFailure> |
Public Member Functions | |
| CDBWrapper (const DBParams ¶ms) | |
| ~CDBWrapper () | |
| CDBWrapper (const CDBWrapper &)=delete | |
| CDBWrapper & | operator= (const CDBWrapper &)=delete |
| template<typename K, typename V> | |
| ReadStatus | TryRead (const K &key, V &value) const |
| Read and deserialize a value from the database, with explicit error discrimination. | |
| template<typename K, typename V> | |
| bool | Read (const K &key, V &value) const |
| Wrapper around TryRead() that preserves the original Read() semantics: returns true on success, false if the key is absent or deserialization fails, and throws dbwrapper_error on an internal DB error. | |
| template<typename K, typename V> | |
| void | Write (const K &key, const V &value, bool fSync=false) |
| template<typename K> | |
| bool | Exists (const K &key) const |
| template<typename K> | |
| void | Erase (const K &key, bool fSync=false) |
| void | WriteBatch (CDBBatch &batch, bool fSync=false) |
| void | CompactFull () |
| Perform a blocking full compaction of the underlying LevelDB. | |
| std::optional< std::string > | GetProperty (const std::string &property) const |
| Return a LevelDB property value, if available. | |
| size_t | DynamicMemoryUsage () const |
| CDBIterator * | NewIterator () |
| bool | IsEmpty () |
| Return true if the database managed by this class contains no entries. | |
| template<typename K> | |
| size_t | EstimateSize (const K &key_begin, const K &key_end) const |
Static Public Member Functions | |
| static bool | HasKeyStartingWith (const fs::path &path, uint8_t prefix) |
Private Member Functions | |
| std::optional< std::string > | ReadImpl (std::span< const std::byte > key) const |
| bool | ExistsImpl (std::span< const std::byte > key) const |
| size_t | EstimateSizeImpl (std::span< const std::byte > key1, std::span< const std::byte > key2) const |
| auto & | DBContext () const LIFETIMEBOUND |
Private Attributes | |
| std::unique_ptr< LevelDBContext > | m_db_context |
| holds all leveldb-specific fields of this class | |
| std::string | m_name |
| the name of this database | |
| Obfuscation | m_obfuscation |
| optional XOR-obfuscation of the database | |
Static Private Attributes | |
| static const std::string | OBFUSCATION_KEY {"\000obfuscate_key", 14} |
| obfuscation key storage key, null-prefixed to avoid collisions | |
Friends | |
| const Obfuscation & | dbwrapper_private::GetObfuscation (const CDBWrapper &) |
Definition at line 192 of file dbwrapper.h.
| using CDBWrapper::ReadStatus = util::Expected<bool, ReadFailure> |
Definition at line 230 of file dbwrapper.h.
| CDBWrapper::CDBWrapper | ( | const DBParams & | params | ) |
Definition at line 244 of file dbwrapper.cpp.
| CDBWrapper::~CDBWrapper | ( | ) |
|
delete |
| void CDBWrapper::CompactFull | ( | ) |
Perform a blocking full compaction of the underlying LevelDB.
Definition at line 334 of file dbwrapper.cpp.
|
inlineprivate |
| size_t CDBWrapper::DynamicMemoryUsage | ( | ) | const |
Definition at line 336 of file dbwrapper.cpp.
|
inline |
Definition at line 316 of file dbwrapper.h.
|
inline |
|
private |
Definition at line 375 of file dbwrapper.cpp.
|
inline |
Definition at line 307 of file dbwrapper.h.
|
private |
Definition at line 360 of file dbwrapper.cpp.
| std::optional< std::string > CDBWrapper::GetProperty | ( | const std::string & | property | ) | const |
Return a LevelDB property value, if available.
Definition at line 328 of file dbwrapper.cpp.
|
static |
Probe an unopened database for a key prefix. Return true if a database at path exists and contains at least 1 entry beginning with prefix; missing or empty databases return false, and database errors throw dbwrapper_error.
Definition at line 156 of file dbwrapper.cpp.
| bool CDBWrapper::IsEmpty | ( | ) |
Return true if the database managed by this class contains no entries.
Definition at line 385 of file dbwrapper.cpp.
| CDBIterator * CDBWrapper::NewIterator | ( | ) |
Definition at line 404 of file dbwrapper.cpp.
|
delete |
|
inline |
Wrapper around TryRead() that preserves the original Read() semantics: returns true on success, false if the key is absent or deserialization fails, and throws dbwrapper_error on an internal DB error.
Prefer TryRead() when the caller needs to distinguish between a missing key and a corrupt value.
Definition at line 287 of file dbwrapper.h.
|
private |
Definition at line 346 of file dbwrapper.cpp.
|
inlinenodiscard |
Read and deserialize a value from the database, with explicit error discrimination.
Unlike Read(), this method distinguishes between a missing key, a deserialization failure (DeserializationError), and an internal DB error (DatabaseError), enabling callers to treat data corruption differently from an absent entry.
| [in] | key | The key to look up. |
| [out] | value | Populated with the deserialized value when the returned Expected holds true; indeterminate otherwise. |
Definition at line 249 of file dbwrapper.h.
|
inline |
Definition at line 299 of file dbwrapper.h.
| void CDBWrapper::WriteBatch | ( | CDBBatch & | batch, |
| bool | fSync = false ) |
Definition at line 312 of file dbwrapper.cpp.
|
friend |
|
private |
holds all leveldb-specific fields of this class
Definition at line 197 of file dbwrapper.h.
|
private |
the name of this database
Definition at line 200 of file dbwrapper.h.
|
private |
optional XOR-obfuscation of the database
Definition at line 203 of file dbwrapper.h.
|
inlinestaticprivate |
obfuscation key storage key, null-prefixed to avoid collisions
Definition at line 206 of file dbwrapper.h.