Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

#include <dbwrapper.h>

+ Inheritance diagram for CDBWrapper:

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 ()
 
CDBIteratorNewIterator ()
 
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]pathLocation in the filesystem where leveldb data will be stored.
[in]nCacheSizeConfigures various leveldb cache settings.
[in]fMemoryIf true, use leveldb's memory environment.
[in]fWipeIf true, remove all existing data.
[in]obfuscateIf 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.

References options, pdb, and penv.

Member Function Documentation

◆ CompactFull()

void CDBWrapper::CompactFull ( ) const
inline

Definition at line 393 of file dbwrapper.h.

References pdb.

Referenced by CDeterministicMNManager::UpgradeDBIfNeeded().

◆ CompactRange()

template<typename K >
void CDBWrapper::CompactRange ( const K &  key_begin,
const K &  key_end 
) const
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()

std::vector< unsigned char > CDBWrapper::CreateObfuscateKey ( ) const
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()

template<typename K >
bool CDBWrapper::Erase ( const K &  key,
bool  fSync = false 
)
inline

◆ EstimateSize()

template<typename K >
size_t CDBWrapper::EstimateSize ( const K &  key_begin,
const K &  key_end 
) const
inline

◆ Exists() [1/2]

◆ Exists() [2/2]

bool CDBWrapper::Exists ( const CDataStream key) const
inline

◆ Flush()

bool CDBWrapper::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()

◆ Read() [1/2]

◆ Read() [2/2]

template<typename V >
bool CDBWrapper::Read ( const CDataStream ssKey,
V &  value 
) const
inline

Definition at line 282 of file dbwrapper.h.

References CLIENT_VERSION, ReadDataStream(), and SER_DISK.

◆ ReadDataStream() [1/2]

template<typename K >
bool CDBWrapper::ReadDataStream ( const K &  key,
CDataStream ssValue 
) const
inline

◆ ReadDataStream() [2/2]

bool CDBWrapper::ReadDataStream ( const CDataStream ssKey,
CDataStream ssValue 
) const
inline

◆ Sync()

bool CDBWrapper::Sync ( )
inline

Definition at line 345 of file dbwrapper.h.

References WriteBatch().

◆ Write()

◆ WriteBatch()

Friends And Related Function Documentation

◆ dbwrapper_private::GetObfuscateKey

const std::vector<unsigned char>& dbwrapper_private::GetObfuscateKey ( const CDBWrapper w)
friend

Member Data Documentation

◆ iteroptions

leveldb::ReadOptions CDBWrapper::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

std::vector<unsigned char> CDBWrapper::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

const std::string CDBWrapper::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

const unsigned int CDBWrapper::OBFUSCATE_KEY_NUM_BYTES = 8
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

leveldb::Options CDBWrapper::options
private

database options used

Definition at line 205 of file dbwrapper.h.

Referenced by CDBWrapper(), and ~CDBWrapper().

◆ pdb

leveldb::DB* 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

leveldb::Env* 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

leveldb::ReadOptions 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

leveldb::WriteOptions CDBWrapper::syncoptions
private

options used when sync writing to the database

Definition at line 217 of file dbwrapper.h.

Referenced by CDBWrapper(), and WriteBatch().

◆ writeoptions

leveldb::WriteOptions CDBWrapper::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:
Released under the MIT license