Bitcoin Core  0.15.99
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
CDBWrapper Class Reference

#include <dbwrapper.h>

Inheritance diagram for CDBWrapper:
[legend]

Public Member Functions

 CDBWrapper (const fs::path &path, size_t nCacheSize, bool fMemory=false, bool fWipe=false, bool obfuscate=false)
 
 ~CDBWrapper ()
 
template<typename K , typename V >
bool Read (const K &key, 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
 
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...
 

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 176 of file dbwrapper.h.

Constructor & Destructor Documentation

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 93 of file dbwrapper.cpp.

Here is the call graph for this function:

CDBWrapper::~CDBWrapper ( )

Definition at line 144 of file dbwrapper.cpp.

Member Function Documentation

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 329 of file dbwrapper.h.

Here is the call graph for this function:

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 177 of file dbwrapper.cpp.

Here is the call graph for this function:

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

Definition at line 278 of file dbwrapper.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 310 of file dbwrapper.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename K >
bool CDBWrapper::Exists ( const K &  key) const
inline

Definition at line 259 of file dbwrapper.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CDBWrapper::Flush ( )
inline

Definition at line 288 of file dbwrapper.h.

bool CDBWrapper::IsEmpty ( )

Return true if the database managed by this class contains no entries.

Definition at line 185 of file dbwrapper.cpp.

CDBIterator* CDBWrapper::NewIterator ( )
inline

Definition at line 299 of file dbwrapper.h.

Here is the caller graph for this function:

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

Definition at line 225 of file dbwrapper.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CDBWrapper::Sync ( )
inline

Definition at line 293 of file dbwrapper.h.

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

Definition at line 251 of file dbwrapper.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CDBWrapper::WriteBatch ( CDBBatch batch,
bool  fSync = false 
)

Definition at line 158 of file dbwrapper.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

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

Member Data Documentation

leveldb::ReadOptions CDBWrapper::iteroptions
private

options used when iterating over values of the database

Definition at line 190 of file dbwrapper.h.

std::vector<unsigned char> CDBWrapper::obfuscate_key
private

a key used for optional XOR-obfuscation of the database

Definition at line 202 of file dbwrapper.h.

const std::string CDBWrapper::OBFUSCATE_KEY_KEY
staticprivate

the key under which the obfuscation key is stored

Definition at line 205 of file dbwrapper.h.

const unsigned int CDBWrapper::OBFUSCATE_KEY_NUM_BYTES = 8
staticprivate

the length of the obfuscate key in number of bytes

Definition at line 208 of file dbwrapper.h.

leveldb::Options CDBWrapper::options
private

database options used

Definition at line 184 of file dbwrapper.h.

leveldb::DB* CDBWrapper::pdb
private

the database itself

Definition at line 199 of file dbwrapper.h.

leveldb::Env* CDBWrapper::penv
private

custom environment this database is using (may be nullptr in case of default environment)

Definition at line 181 of file dbwrapper.h.

leveldb::ReadOptions CDBWrapper::readoptions
private

options used when reading from the database

Definition at line 187 of file dbwrapper.h.

leveldb::WriteOptions CDBWrapper::syncoptions
private

options used when sync writing to the database

Definition at line 196 of file dbwrapper.h.

leveldb::WriteOptions CDBWrapper::writeoptions
private

options used when writing to the database

Definition at line 193 of file dbwrapper.h.


The documentation for this class was generated from the following files: