![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include <dbwrapper.h>
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) |
CDBIterator * | NewIterator () |
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... | |
Definition at line 135 of file dbwrapper.h.
CDBWrapper::CDBWrapper | ( | const boost::filesystem::path & | path, |
size_t | nCacheSize, | ||
bool | fMemory = false , |
||
bool | fWipe = false , |
||
bool | obfuscate = false |
||
) |
[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 48 of file dbwrapper.cpp.
CDBWrapper::~CDBWrapper | ( | ) |
Definition at line 93 of file dbwrapper.cpp.
|
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().
|
inline |
Definition at line 236 of file dbwrapper.h.
Referenced by CBlockTreeDB::WriteReindexing().
|
inline |
Definition at line 217 of file dbwrapper.h.
Referenced by CCoinsViewDB::HaveCoins(), and CBlockTreeDB::ReadReindexing().
|
inline |
Definition at line 246 of file dbwrapper.h.
const std::vector< unsigned char > & CDBWrapper::GetObfuscateKey | ( | ) | const |
Accessor for obfuscate_key.
Definition at line 139 of file dbwrapper.cpp.
Referenced by CCoinsViewDB::BatchWrite(), CBlockTreeDB::EraseAddressIndex(), CBlockTreeDB::UpdateAddressUnspentIndex(), CBlockTreeDB::UpdateSpentIndex(), CBlockTreeDB::WriteAddressIndex(), CBlockTreeDB::WriteBatchSync(), CBlockTreeDB::WriteTimestampIndex(), and CBlockTreeDB::WriteTxIndex().
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().
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().
|
inline |
Definition at line 257 of file dbwrapper.h.
Referenced by IsEmpty(), CBlockTreeDB::LoadBlockIndexGuts(), CBlockTreeDB::ReadAddressIndex(), CBlockTreeDB::ReadAddressUnspentIndex(), and CBlockTreeDB::ReadTimestampIndex().
|
inline |
Definition at line 183 of file dbwrapper.h.
Referenced by CDBWrapper(), CCoinsViewDB::GetBestBlock(), CCoinsViewDB::GetCoins(), CBlockTreeDB::ReadBlockFileInfo(), CBlockTreeDB::ReadFlag(), CBlockTreeDB::ReadLastBlockFile(), CBlockTreeDB::ReadSpentIndex(), and CBlockTreeDB::ReadTxIndex().
|
inline |
Definition at line 251 of file dbwrapper.h.
|
inline |
Definition at line 209 of file dbwrapper.h.
Referenced by CDBWrapper(), CBlockTreeDB::WriteFlag(), and CBlockTreeDB::WriteReindexing().
bool CDBWrapper::WriteBatch | ( | CDBBatch & | batch, |
bool | fSync = false |
||
) | |||
throw | ( | dbwrapper_error | |
) |
Definition at line 105 of file dbwrapper.cpp.
Referenced by CCoinsViewDB::BatchWrite(), Erase(), CBlockTreeDB::EraseAddressIndex(), Sync(), CBlockTreeDB::UpdateAddressUnspentIndex(), CBlockTreeDB::UpdateSpentIndex(), Write(), CBlockTreeDB::WriteAddressIndex(), CBlockTreeDB::WriteBatchSync(), CBlockTreeDB::WriteTimestampIndex(), and CBlockTreeDB::WriteTxIndex().
|
private |
options used when iterating over values of the database
Definition at line 148 of file dbwrapper.h.
Referenced by CDBWrapper(), and NewIterator().
|
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().
|
staticprivate |
the key under which the obfuscation key is stored
Definition at line 163 of file dbwrapper.h.
Referenced by CDBWrapper().
|
staticprivate |
the length of the obfuscate key in number of bytes
Definition at line 166 of file dbwrapper.h.
Referenced by CDBWrapper(), and CreateObfuscateKey().
|
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().
|
private |
the database itself
Definition at line 157 of file dbwrapper.h.
Referenced by CDBWrapper(), Exists(), NewIterator(), Read(), and ~CDBWrapper().
|
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().
|
private |
options used when reading from the database
Definition at line 145 of file dbwrapper.h.
Referenced by CDBWrapper(), Exists(), and Read().
|
private |
options used when sync writing to the database
Definition at line 154 of file dbwrapper.h.
Referenced by CDBWrapper().
|
private |
options used when writing to the database
Definition at line 151 of file dbwrapper.h.