Dash Core  0.12.2.1
P2P Digital Currency
CDBWrapper Class Reference

#include <dbwrapper.h>

+ Inheritance diagram for CDBWrapper:

Public Member Functions

 CDBWrapper (const boost::filesystem::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 throw (dbwrapper_error)
 
template<typename K , typename V >
bool Write (const K &key, const V &value, bool fSync=false) throw (dbwrapper_error)
 
template<typename K >
bool Exists (const K &key) const throw (dbwrapper_error)
 
template<typename K >
bool Erase (const K &key, bool fSync=false) throw (dbwrapper_error)
 
bool WriteBatch (CDBBatch &batch, bool fSync=false) throw (dbwrapper_error)
 
bool Flush ()
 
bool Sync () throw (dbwrapper_error)
 
CDBIteratorNewIterator ()
 
bool IsEmpty ()
 
const std::vector< unsigned char > & GetObfuscateKey () const
 
std::string GetObfuscateKeyHex () const
 

Private Member Functions

std::vector< unsigned char > CreateObfuscateKey () const
 

Private Attributes

leveldb::Env * penv
 custom environment this database is using (may be NULL 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...
 

Detailed Description

Definition at line 135 of file dbwrapper.h.

Constructor & Destructor Documentation

◆ CDBWrapper()

CDBWrapper::CDBWrapper ( const boost::filesystem::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 48 of file dbwrapper.cpp.

◆ ~CDBWrapper()

CDBWrapper::~CDBWrapper ( )

Definition at line 93 of file dbwrapper.cpp.

Member Function Documentation

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

Referenced by CDBWrapper().

◆ Erase()

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

Definition at line 236 of file dbwrapper.h.

Referenced by CBlockTreeDB::WriteReindexing().

◆ Exists()

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

Definition at line 217 of file dbwrapper.h.

Referenced by CCoinsViewDB::HaveCoins(), and CBlockTreeDB::ReadReindexing().

◆ Flush()

bool CDBWrapper::Flush ( )
inline

Definition at line 246 of file dbwrapper.h.

◆ GetObfuscateKey()

◆ GetObfuscateKeyHex()

std::string CDBWrapper::GetObfuscateKeyHex ( ) const

Return the obfuscate_key as a hex-formatted string.

Definition at line 144 of file dbwrapper.cpp.

Referenced by CDBWrapper().

◆ IsEmpty()

bool CDBWrapper::IsEmpty ( )

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

Definition at line 132 of file dbwrapper.cpp.

Referenced by CDBWrapper().

◆ NewIterator()

◆ Read()

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

◆ Sync()

bool CDBWrapper::Sync ( )
throw (dbwrapper_error
)
inline

Definition at line 251 of file dbwrapper.h.

◆ Write()

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

Definition at line 209 of file dbwrapper.h.

Referenced by CDBWrapper(), CBlockTreeDB::WriteFlag(), and CBlockTreeDB::WriteReindexing().

◆ WriteBatch()

Member Data Documentation

◆ iteroptions

leveldb::ReadOptions CDBWrapper::iteroptions
private

options used when iterating over values of the database

Definition at line 148 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 160 of file dbwrapper.h.

Referenced by CDBWrapper(), Erase(), GetObfuscateKey(), GetObfuscateKeyHex(), NewIterator(), Read(), Sync(), and Write().

◆ OBFUSCATE_KEY_KEY

const std::string CDBWrapper::OBFUSCATE_KEY_KEY
staticprivate

the key under which the obfuscation key is stored

Definition at line 163 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 166 of file dbwrapper.h.

Referenced by CDBWrapper(), and CreateObfuscateKey().

◆ options

leveldb::Options CDBWrapper::options
private

database options used

Definition at line 142 of file dbwrapper.h.

Referenced by CDBWrapper(), pruning.PruneTest::create_chain_with_staleblocks(), walletbackup.WalletBackupTest::erase_three(), test_framework.test_framework.BitcoinTestFramework::main(), reindex.ReindexTest::reindex(), pruning.PruneTest::reorg_test(), keypool-hd.KeyPoolTest::run_test(), keypool.KeyPoolTest::run_test(), abandonconflict.AbandonConflictTest::run_test(), nodehandling.NodeHandlingTest::run_test(), txn_clone.TxnMallTest::run_test(), txn_doublespend.TxnMallTest::run_test(), zapwallettxes.ZapWalletTXesTest::run_test(), invalidtxrequest.InvalidTxRequestTest::run_test(), wallet-hd.WalletHDTest::run_test(), fundrawtransaction-hd.RawTransactionsTest::run_test(), fundrawtransaction.RawTransactionsTest::run_test(), invalidblockrequest.InvalidBlockRequestTest::run_test(), wallet.WalletTest::run_test(), p2p-fullblocktest.FullBlockTest::run_test(), bip65-cltv-p2p.BIP65Test::run_test(), bipdersig-p2p.BIP66Test::run_test(), p2p-versionbits-warning.VersionBitsWarningTest::run_test(), walletbackup.WalletBackupTest::run_test(), bip68-112-113-p2p.BIP68_112_113Test::run_test(), maxuploadtarget.MaxUploadTest::run_test(), fundrawtransaction-hd.RawTransactionsTest::setup_chain(), fundrawtransaction.RawTransactionsTest::setup_chain(), zapwallettxes.ZapWalletTXesTest::setup_chain(), signrawtransactions.SignRawTransactionsTest::setup_chain(), decodescript.DecodeScriptTest::setup_chain(), wallet-hd.WalletHDTest::setup_chain(), reindex.ReindexTest::setup_chain(), merkle_blocks.MerkleBlockTest::setup_chain(), disablewallet.DisableWalletTest::setup_chain(), invalidateblock.InvalidateTest::setup_chain(), rawtransactions.RawTransactionsTest::setup_chain(), timestampindex.TimestampIndexTest::setup_chain(), addressindex.AddressIndexTest::setup_chain(), prioritise_transaction.PrioritiseTransactionTest::setup_chain(), txindex.TxIndexTest::setup_chain(), spentindex.SpentIndexTest::setup_chain(), mempool_limit.MempoolLimitTest::setup_chain(), wallet.WalletTest::setup_chain(), pruning.PruneTest::setup_chain(), multi_rpc.HTTPBasicsTest::setup_chain(), blockchain.BlockchainTest::setup_chain(), walletbackup.WalletBackupTest::setup_chain(), rest.RESTTest::setup_chain(), p2p-versionbits-warning.VersionBitsWarningTest::setup_chain(), keypool.KeyPoolTest::setup_chain(), maxblocksinflight.MaxBlocksInFlightTest::setup_chain(), maxuploadtarget.MaxUploadTest::setup_chain(), keypool-hd.KeyPoolTest::setup_chain(), p2p-acceptblock.AcceptBlockTest::setup_chain(), test_framework.test_framework.ComparisonTestFramework::setup_chain(), sendheaders.SendHeadersTest::setup_chain(), listtransactions.ListTransactionsTest::setup_nodes(), httpbasics.HTTPBasicsTest::setup_nodes(), multi_rpc.HTTPBasicsTest::setup_nodes(), receivedby.ReceivedByTest::setup_nodes(), test_framework.test_framework.BitcoinTestFramework::setup_nodes(), proxy_test.ProxyTest::setup_nodes(), walletbackup.WalletBackupTest::start_three(), and ~CDBWrapper().

◆ pdb

leveldb::DB* CDBWrapper::pdb
private

the database itself

Definition at line 157 of file dbwrapper.h.

Referenced by CDBWrapper(), Exists(), NewIterator(), Read(), and ~CDBWrapper().

◆ penv

leveldb::Env* CDBWrapper::penv
private

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

Definition at line 139 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 145 of file dbwrapper.h.

Referenced by CDBWrapper(), Exists(), and Read().

◆ syncoptions

leveldb::WriteOptions CDBWrapper::syncoptions
private

options used when sync writing to the database

Definition at line 154 of file dbwrapper.h.

Referenced by CDBWrapper().

◆ writeoptions

leveldb::WriteOptions CDBWrapper::writeoptions
private

options used when writing to the database

Definition at line 151 of file dbwrapper.h.


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