Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <dbwrapper.h>
Public Member Functions | |
CDBWrapper (const fs::path &path, size_t nCacheSize, bool fMemory=false, bool fWipe=false, bool obfuscate=false) | |
~CDBWrapper () | |
template<typename K > | |
bool | ReadDataStream (const K &key, CDataStream &ssValue) const |
bool | ReadDataStream (const CDataStream &ssKey, CDataStream &ssValue) const |
template<typename K , typename V > | |
bool | Read (const K &key, V &value) const |
template<typename V > | |
bool | Read (const CDataStream &ssKey, V &value) const |
template<typename K , typename V > | |
bool | Write (const K &key, const V &value, bool fSync=false) |
template<typename K > | |
bool | Exists (const K &key) const |
bool | Exists (const CDataStream &key) const |
template<typename K > | |
bool | Erase (const K &key, bool fSync=false) |
bool | WriteBatch (CDBBatch &batch, bool fSync=false) |
bool | Flush () |
bool | Sync () |
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 |
template<typename K > | |
void | CompactRange (const K &key_begin, const K &key_end) const |
Compact a certain range of keys in the database. More... | |
void | CompactFull () const |
Private Member Functions | |
std::vector< unsigned char > | CreateObfuscateKey () const |
Returns a string (consisting of 8 random bytes) suitable for use as an obfuscating XOR key. More... | |
Private Attributes | |
leveldb::Env * | penv |
custom environment this database is using (may be nullptr in case of default environment) More... | |
leveldb::Options | options |
database options used More... | |
leveldb::ReadOptions | readoptions |
options used when reading from the database More... | |
leveldb::ReadOptions | iteroptions |
options used when iterating over values of the database More... | |
leveldb::WriteOptions | writeoptions |
options used when writing to the database More... | |
leveldb::WriteOptions | syncoptions |
options used when sync writing to the database More... | |
leveldb::DB * | pdb |
the database itself More... | |
std::vector< unsigned char > | obfuscate_key |
a key used for optional XOR-obfuscation of the database More... | |
Static Private Attributes | |
static const std::string | OBFUSCATE_KEY_KEY |
the key under which the obfuscation key is stored More... | |
static const unsigned int | OBFUSCATE_KEY_NUM_BYTES = 8 |
the length of the obfuscate key in number of bytes More... | |
Friends | |
const std::vector< unsigned char > & | dbwrapper_private::GetObfuscateKey (const CDBWrapper &w) |
Detailed Description
Definition at line 197 of file dbwrapper.h.
Constructor & Destructor Documentation
◆ CDBWrapper()
CDBWrapper::CDBWrapper | ( | const fs::path & | path, |
size_t | nCacheSize, | ||
bool | fMemory = false , |
||
bool | fWipe = false , |
||
bool | obfuscate = false |
||
) |
- Parameters
-
[in] path Location in the filesystem where leveldb data will be stored. [in] nCacheSize Configures various leveldb cache settings. [in] fMemory If true, use leveldb's memory environment. [in] fWipe If true, remove all existing data. [in] obfuscate If true, store data obfuscated via simple XOR. If false, XOR with a zero'd byte array.
Definition at line 92 of file dbwrapper.cpp.
References CreateObfuscateKey(), gArgs, ArgsManager::GetBoolArg(), GetOptions(), dbwrapper_private::HandleError(), HexStr(), IsEmpty(), iteroptions, LogPrintf, obfuscate_key, OBFUSCATE_KEY_KEY, OBFUSCATE_KEY_NUM_BYTES, options, pdb, penv, Read(), readoptions, syncoptions, TryCreateDirectories(), and Write().
◆ ~CDBWrapper()
CDBWrapper::~CDBWrapper | ( | ) |
Definition at line 143 of file dbwrapper.cpp.
Member Function Documentation
◆ CompactFull()
|
inline |
Definition at line 393 of file dbwrapper.h.
References pdb.
Referenced by CDeterministicMNManager::UpgradeDBIfNeeded().
◆ CompactRange()
|
inline |
Compact a certain range of keys in the database.
Definition at line 381 of file dbwrapper.h.
References CLIENT_VERSION, CDataStream::data(), DBWRAPPER_PREALLOC_KEY_SIZE, pdb, CDataStream::reserve(), SER_DISK, and CDataStream::size().
Referenced by CCoinsViewDB::Upgrade().
◆ CreateObfuscateKey()
|
private |
Returns a string (consisting of 8 random bytes) suitable for use as an obfuscating XOR key.
Definition at line 176 of file dbwrapper.cpp.
References GetRandBytes(), and OBFUSCATE_KEY_NUM_BYTES.
Referenced by CDBWrapper().
◆ Erase()
|
inline |
Definition at line 330 of file dbwrapper.h.
References CDBBatch::Erase(), and WriteBatch().
Referenced by llmq::CInstantSendDb::RemoveInstantSendLockMined(), CDeterministicMNManager::UpgradeDBIfNeeded(), and CBlockTreeDB::WriteReindexing().
◆ EstimateSize()
|
inline |
Definition at line 362 of file dbwrapper.h.
References CLIENT_VERSION, CDataStream::data(), DBWRAPPER_PREALLOC_KEY_SIZE, pdb, CDataStream::reserve(), SER_DISK, and CDataStream::size().
Referenced by CCoinsViewDB::EstimateSize().
◆ Exists() [1/2]
|
inline |
Definition at line 306 of file dbwrapper.h.
References CLIENT_VERSION, DBWRAPPER_PREALLOC_KEY_SIZE, CDataStream::reserve(), and SER_DISK.
Referenced by llmq::CRecoveredSigsDb::CRecoveredSigsDb(), llmq::CInstantSendDb::HasArchivedInstantSendLock(), llmq::CRecoveredSigsDb::HasRecoveredSig(), llmq::CRecoveredSigsDb::HasRecoveredSigForHash(), llmq::CRecoveredSigsDb::HasRecoveredSigForId(), llmq::CRecoveredSigsDb::HasRecoveredSigForSession(), CBlockTreeDB::HasTxIndex(), llmq::CRecoveredSigsDb::HasVotedOnId(), CCoinsViewDB::HaveCoin(), CBlockTreeDB::ReadReindexing(), and CDeterministicMNManager::UpgradeDBIfNeeded().
◆ Exists() [2/2]
|
inline |
Definition at line 314 of file dbwrapper.h.
References CDataStream::data(), dbwrapper_private::HandleError(), LogPrintf, pdb, readoptions, and CDataStream::size().
◆ Flush()
|
inline |
Definition at line 340 of file dbwrapper.h.
◆ IsEmpty()
bool CDBWrapper::IsEmpty | ( | ) |
Return true if the database managed by this class contains no entries.
Definition at line 184 of file dbwrapper.cpp.
References NewIterator().
Referenced by CDBWrapper().
◆ NewIterator()
|
inline |
Definition at line 351 of file dbwrapper.h.
References iteroptions, and pdb.
Referenced by llmq::CRecoveredSigsDb::AddVoteTimeKeys(), llmq::CRecoveredSigsDb::CleanupOldRecoveredSigs(), llmq::CRecoveredSigsDb::CleanupOldVotes(), llmq::CRecoveredSigsDb::ConvertInvalidTimeKeys(), llmq::CInstantSendDb::GetInstantSendLockCount(), llmq::CInstantSendDb::GetInstantSendLocksByParent(), IsEmpty(), CBlockTreeDB::LoadBlockIndexGuts(), CBlockTreeDB::ReadAddressIndex(), CBlockTreeDB::ReadAddressUnspentIndex(), CBlockTreeDB::ReadTimestampIndex(), llmq::CInstantSendDb::RemoveArchivedInstantSendLocks(), llmq::CInstantSendDb::RemoveConfirmedInstantSendLocks(), and CCoinsViewDB::Upgrade().
◆ Read() [1/2]
|
inline |
Definition at line 273 of file dbwrapper.h.
References CLIENT_VERSION, DBWRAPPER_PREALLOC_KEY_SIZE, CDataStream::reserve(), and SER_DISK.
Referenced by CDBWrapper(), CCoinsViewDB::GetBestBlock(), CCoinsViewDB::GetCoin(), CCoinsViewDB::GetHeadBlocks(), llmq::CInstantSendDb::GetInstantSendLockByHash(), llmq::CInstantSendDb::GetInstantSendLockByInput(), llmq::CInstantSendDb::GetInstantSendLockHashByTxid(), llmq::CRecoveredSigsDb::GetRecoveredSigByHash(), llmq::CDKGSessionManager::GetVerifiedContribution(), llmq::CRecoveredSigsDb::GetVoteForId(), CBlockTreeDB::ReadBlockFileInfo(), CBlockTreeDB::ReadFlag(), CBlockTreeDB::ReadLastBlockFile(), CBlockTreeDB::ReadSpentIndex(), CBlockTreeDB::ReadTxIndex(), and llmq::CQuorumBlockProcessor::UpgradeDB().
◆ Read() [2/2]
|
inline |
Definition at line 282 of file dbwrapper.h.
References CLIENT_VERSION, ReadDataStream(), and SER_DISK.
◆ ReadDataStream() [1/2]
|
inline |
Definition at line 246 of file dbwrapper.h.
References CLIENT_VERSION, DBWRAPPER_PREALLOC_KEY_SIZE, CDataStream::reserve(), and SER_DISK.
Referenced by Read(), llmq::CRecoveredSigsDb::ReadRecoveredSig(), llmq::CRecoveredSigsDb::RemoveRecoveredSig(), and CDeterministicMNManager::UpgradeDiff().
◆ ReadDataStream() [2/2]
|
inline |
Definition at line 254 of file dbwrapper.h.
References CLIENT_VERSION, CDataStream::data(), dbwrapper_private::HandleError(), LogPrintf, obfuscate_key, pdb, readoptions, SER_DISK, CDataStream::size(), and CDataStream::Xor().
◆ Sync()
|
inline |
Definition at line 345 of file dbwrapper.h.
References WriteBatch().
◆ Write()
|
inline |
Definition at line 298 of file dbwrapper.h.
References CDBBatch::Write(), and WriteBatch().
Referenced by CDBWrapper(), llmq::CRecoveredSigsDb::CRecoveredSigsDb(), llmq::CQuorumBlockProcessor::UpgradeDB(), CBlockTreeDB::WriteFlag(), llmq::CInstantSendDb::WriteInstantSendLockMined(), CBlockTreeDB::WriteReindexing(), llmq::CDKGSessionManager::WriteVerifiedSkContribution(), and llmq::CDKGSessionManager::WriteVerifiedVvecContribution().
◆ WriteBatch()
Definition at line 157 of file dbwrapper.cpp.
References CDBBatch::batch, dbwrapper_private::HandleError(), pdb, syncoptions, and writeoptions.
Referenced by llmq::CRecoveredSigsDb::AddVoteTimeKeys(), CCoinsViewDB::BatchWrite(), llmq::CRecoveredSigsDb::CleanupOldRecoveredSigs(), llmq::CRecoveredSigsDb::CleanupOldVotes(), CEvoDB::CommitRootTransaction(), llmq::CRecoveredSigsDb::ConvertInvalidTimeKeys(), Erase(), CBlockTreeDB::EraseAddressIndex(), llmq::CInstantSendDb::RemoveArchivedInstantSendLocks(), llmq::CInstantSendDb::RemoveChainedInstantSendLocks(), llmq::CInstantSendDb::RemoveConfirmedInstantSendLocks(), llmq::CRecoveredSigsDb::RemoveRecoveredSig(), Sync(), llmq::CRecoveredSigsDb::TruncateRecoveredSig(), CBlockTreeDB::UpdateAddressUnspentIndex(), CBlockTreeDB::UpdateSpentIndex(), CCoinsViewDB::Upgrade(), CDeterministicMNManager::UpgradeDBIfNeeded(), Write(), CBlockTreeDB::WriteAddressIndex(), CBlockTreeDB::WriteBatchSync(), llmq::CInstantSendDb::WriteNewInstantSendLock(), llmq::CRecoveredSigsDb::WriteRecoveredSig(), CBlockTreeDB::WriteTimestampIndex(), CBlockTreeDB::WriteTxIndex(), and llmq::CRecoveredSigsDb::WriteVoteForId().
Friends And Related Function Documentation
◆ dbwrapper_private::GetObfuscateKey
|
friend |
Member Data Documentation
◆ iteroptions
|
private |
options used when iterating over values of the database
Definition at line 211 of file dbwrapper.h.
Referenced by CDBWrapper(), and NewIterator().
◆ obfuscate_key
|
private |
a key used for optional XOR-obfuscation of the database
Definition at line 223 of file dbwrapper.h.
Referenced by CDBWrapper(), dbwrapper_private::GetObfuscateKey(), and ReadDataStream().
◆ OBFUSCATE_KEY_KEY
|
staticprivate |
the key under which the obfuscation key is stored
Definition at line 226 of file dbwrapper.h.
Referenced by CDBWrapper().
◆ OBFUSCATE_KEY_NUM_BYTES
|
staticprivate |
the length of the obfuscate key in number of bytes
Definition at line 229 of file dbwrapper.h.
Referenced by CDBWrapper(), and CreateObfuscateKey().
◆ options
|
private |
database options used
Definition at line 205 of file dbwrapper.h.
Referenced by CDBWrapper(), and ~CDBWrapper().
◆ pdb
|
private |
the database itself
Definition at line 220 of file dbwrapper.h.
Referenced by CDBWrapper(), CompactFull(), CompactRange(), EstimateSize(), Exists(), NewIterator(), ReadDataStream(), WriteBatch(), and ~CDBWrapper().
◆ penv
|
private |
custom environment this database is using (may be nullptr in case of default environment)
Definition at line 202 of file dbwrapper.h.
Referenced by CDBWrapper(), and ~CDBWrapper().
◆ readoptions
|
private |
options used when reading from the database
Definition at line 208 of file dbwrapper.h.
Referenced by CDBWrapper(), Exists(), and ReadDataStream().
◆ syncoptions
|
private |
options used when sync writing to the database
Definition at line 217 of file dbwrapper.h.
Referenced by CDBWrapper(), and WriteBatch().
◆ writeoptions
|
private |
options used when writing to the database
Definition at line 214 of file dbwrapper.h.
Referenced by WriteBatch().
The documentation for this class was generated from the following files:
- src/dbwrapper.h
- src/dbwrapper.cpp