#include <dbwrapper.h>
|
| | 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. More...
|
| |
| 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. More...
|
| |
| 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. More...
|
| |
| std::optional< std::string > | GetProperty (const std::string &property) const |
| | Return a LevelDB property value, if available. More...
|
| |
| size_t | DynamicMemoryUsage () const |
| |
| CDBIterator * | NewIterator () |
| |
| bool | IsEmpty () |
| | Return true if the database managed by this class contains no entries. More...
|
| |
| template<typename K > |
| size_t | EstimateSize (const K &key_begin, const K &key_end) const |
| |
|
| static const std::string | OBFUSCATION_KEY {"\000obfuscate_key", 14} |
| | obfuscation key storage key, null-prefixed to avoid collisions More...
|
| |
Definition at line 192 of file dbwrapper.h.
◆ ReadStatus
◆ CDBWrapper() [1/2]
| CDBWrapper::CDBWrapper |
( |
const DBParams & |
params | ) |
|
◆ ~CDBWrapper()
| CDBWrapper::~CDBWrapper |
( |
| ) |
|
◆ CDBWrapper() [2/2]
◆ CompactFull()
| void CDBWrapper::CompactFull |
( |
| ) |
|
Perform a blocking full compaction of the underlying LevelDB.
Definition at line 334 of file dbwrapper.cpp.
◆ DBContext()
| auto & CDBWrapper::DBContext |
( |
| ) |
const |
|
inlineprivate |
◆ DynamicMemoryUsage()
| size_t CDBWrapper::DynamicMemoryUsage |
( |
| ) |
const |
◆ Erase()
| void CDBWrapper::Erase |
( |
const K & |
key, |
|
|
bool |
fSync = false |
|
) |
| |
|
inline |
◆ EstimateSize()
| size_t CDBWrapper::EstimateSize |
( |
const K & |
key_begin, |
|
|
const K & |
key_end |
|
) |
| const |
|
inline |
◆ EstimateSizeImpl()
| size_t CDBWrapper::EstimateSizeImpl |
( |
std::span< const std::byte > |
key1, |
|
|
std::span< const std::byte > |
key2 |
|
) |
| const |
|
private |
◆ Exists()
| bool CDBWrapper::Exists |
( |
const K & |
key | ) |
const |
|
inline |
◆ ExistsImpl()
| bool CDBWrapper::ExistsImpl |
( |
std::span< const std::byte > |
key | ) |
const |
|
private |
◆ GetProperty()
| 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.
◆ HasKeyStartingWith()
| bool CDBWrapper::HasKeyStartingWith |
( |
const fs::path & |
path, |
|
|
uint8_t |
prefix |
|
) |
| |
|
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.
◆ IsEmpty()
| bool CDBWrapper::IsEmpty |
( |
| ) |
|
Return true if the database managed by this class contains no entries.
Definition at line 385 of file dbwrapper.cpp.
◆ NewIterator()
◆ operator=()
◆ Read()
template<typename
K , typename V >
| bool CDBWrapper::Read |
( |
const K & |
key, |
|
|
V & |
value |
|
) |
| const |
|
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.
◆ ReadImpl()
| std::optional< std::string > CDBWrapper::ReadImpl |
( |
std::span< const std::byte > |
key | ) |
const |
|
private |
◆ TryRead()
template<typename
K , typename V >
| ReadStatus CDBWrapper::TryRead |
( |
const K & |
key, |
|
|
V & |
value |
|
) |
| const |
|
inline |
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.
- Note
- Callers are expected to provide well-formed keys; key serialization is the only operation that may throw.
- Parameters
-
| [in] | key | The key to look up. |
| [out] | value | Populated with the deserialized value when the returned Expected holds true; indeterminate otherwise. |
- Returns
- On success, true if the key was found (value populated) or false if the key was absent. On failure, a ReadFailure describing the error.
Definition at line 249 of file dbwrapper.h.
◆ Write()
template<typename
K , typename V >
| void CDBWrapper::Write |
( |
const K & |
key, |
|
|
const V & |
value, |
|
|
bool |
fSync = false |
|
) |
| |
|
inline |
◆ WriteBatch()
| void CDBWrapper::WriteBatch |
( |
CDBBatch & |
batch, |
|
|
bool |
fSync = false |
|
) |
| |
◆ dbwrapper_private::GetObfuscation
◆ m_db_context
holds all leveldb-specific fields of this class
Definition at line 197 of file dbwrapper.h.
◆ m_name
| std::string CDBWrapper::m_name |
|
private |
◆ m_obfuscation
optional XOR-obfuscation of the database
Definition at line 203 of file dbwrapper.h.
◆ OBFUSCATION_KEY
| const std::string CDBWrapper::OBFUSCATION_KEY {"\000obfuscate_key", 14} |
|
inlinestaticprivate |
obfuscation key storage key, null-prefixed to avoid collisions
Definition at line 206 of file dbwrapper.h.
The documentation for this class was generated from the following files: