Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
dbwrapper.h
Go to the documentation of this file.
66 explicit CDBBatch(const CDBWrapper &_parent) : parent(_parent), ssKey(SER_DISK, CLIENT_VERSION), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0) { };
99 size_estimate += 3 + (slKey.size() > 127) + slKey.size() + (slValue.size() > 127) + slValue.size();
199 friend const std::vector<unsigned char>& dbwrapper_private::GetObfuscateKey(const CDBWrapper &w);
242 CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false, bool obfuscate = false);
266 CDataStream ssValueTmp(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION);
406 typedef typename std::remove_pointer<decltype(transaction.parent.NewIterator())>::type ParentIterator;
409 // At all times, only one of both provides the current value. The decision is made by comparing the current keys
410 // of both iterators, so that always the smaller key is the current one. On Next(), the previously chosen iterator
558 ssize_t memoryUsage{0}; // signed, just in case we made an error in the calculations so that we don't get an overflow
581 ValueHolderImpl(const V &_value, size_t _memoryUsage) : ValueHolder(_memoryUsage), value(_value) {}
584 // we're moving the value instead of copying it. This means that Write() can only be called once per
606 CDBTransaction(Parent &_parent, CommitTarget &_commitTarget) : parent(_parent), commitTarget(_commitTarget) {}
These should be considered an implementation detail of the specific database.
Definition: dbwrapper.cpp:196
Definition: dbwrapper.h:126
Definition: util.h:116
CDBWrapper(const fs::path &path, size_t nCacheSize, bool fMemory=false, bool fWipe=false, bool obfuscate=false)
Definition: dbwrapper.cpp:92
size_t GetSerializeSize(const T &t, int nType, int nVersion=0)
Definition: serialize.h:1295
Definition: dbwrapper.h:571
ValueHolderImpl(const V &_value, size_t _memoryUsage)
Definition: dbwrapper.h:581
static const size_t DBWRAPPER_PREALLOC_KEY_SIZE
Definition: dbwrapper.h:21
Definition: dbwrapper.h:197
void SkipDeletedAndOverwritten()
Definition: dbwrapper.h:526
void Xor(const std::vector< unsigned char > &key)
XOR the contents of this stream with a certain key.
Definition: streams.h:376
Definition: box.hpp:161
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
void HandleError(const leveldb::Status &status)
Handle database error by throwing dbwrapper_error exception.
Definition: dbwrapper.cpp:198
std::remove_pointer< decltype(transaction.parent.NewIterator())>::type ParentIterator
Definition: dbwrapper.h:406
Definition: dbwrapper.h:552
bool ReadDataStream(const K &key, CDataStream &ssValue) const
Definition: dbwrapper.h:246
std::vector< unsigned char > CreateObfuscateKey() const
Returns a string (consisting of 8 random bytes) suitable for use as an obfuscating XOR key...
Definition: dbwrapper.cpp:176
virtual void Write(const CDataStream &ssKey, CommitTarget &commitTarget)
Definition: dbwrapper.h:583
Definition: dbwrapper.h:401
leveldb::ReadOptions readoptions
options used when reading from the database
Definition: dbwrapper.h:208
Definition: dbwrapper.h:560
leveldb::WriteOptions syncoptions
options used when sync writing to the database
Definition: dbwrapper.h:217
CDBTransactionIterator< CDBTransaction > * NewIterator()
Definition: dbwrapper.h:719
leveldb::ReadOptions iteroptions
options used when iterating over values of the database
Definition: dbwrapper.h:211
virtual void Write(const CDataStream &ssKey, CommitTarget &parent)=0
Definition: dbwrapper.h:24
leveldb::WriteOptions writeoptions
options used when writing to the database
Definition: dbwrapper.h:214
CDBTransactionIterator(CDBTransaction &_transaction)
Definition: dbwrapper.h:418
bool IsEmpty()
Return true if the database managed by this class contains no entries.
Definition: dbwrapper.cpp:184
std::unique_ptr< ParentIterator > parentIt
Definition: dbwrapper.h:413
static CDataStream KeyToDataStream(const K &key)
Definition: dbwrapper.h:592
CDBTransaction(Parent &_parent, CommitTarget &_commitTarget)
Definition: dbwrapper.h:606
const std::vector< unsigned char > & GetObfuscateKey(const CDBWrapper &w)
Work around circular dependency, as well as for testing in dbwrapper_tests.
Definition: dbwrapper.cpp:212
virtual ~ValueHolder()=default
static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE
Definition: dbwrapper.h:22
static const unsigned int OBFUSCATE_KEY_NUM_BYTES
the length of the obfuscate key in number of bytes
Definition: dbwrapper.h:229
bool Write(const K &key, const V &value, bool fSync=false)
Definition: dbwrapper.h:298
void CompactRange(const K &key_begin, const K &key_end) const
Compact a certain range of keys in the database.
Definition: dbwrapper.h:381
leveldb::Env * penv
custom environment this database is using (may be nullptr in case of default environment) ...
Definition: dbwrapper.h:202
CDBIterator(const CDBWrapper &_parent, leveldb::Iterator *_piter)
Definition: dbwrapper.h:138
static const std::string OBFUSCATE_KEY_KEY
the key under which the obfuscation key is stored
Definition: dbwrapper.h:226
Definition: dbwrapper.h:580
std::unique_ptr< ValueHolder > ValueHolderPtr
Definition: dbwrapper.h:577
bool WriteBatch(CDBBatch &batch, bool fSync=false)
Definition: dbwrapper.cpp:157
CDBTransaction::WritesMap::iterator transactionIt
Definition: dbwrapper.h:412
bool operator()(const CDataStream &a, const CDataStream &b) const
Definition: dbwrapper.h:566
bool ReadDataStream(const CDataStream &ssKey, CDataStream &ssValue) const
Definition: dbwrapper.h:254
std::unique_ptr< CDBTransactionIterator< CDBTransaction > > NewIteratorUniquePtr()
Definition: dbwrapper.h:722
std::vector< unsigned char > obfuscate_key
a key used for optional XOR-obfuscation of the database
Definition: dbwrapper.h:223
size_t EstimateSize(const K &key_begin, const K &key_end) const
Definition: dbwrapper.h:362
static const int CLIENT_VERSION
dashd-res.rc includes this file, but it cannot cope with real c++ code.
Definition: clientversion.h:38
std::map< CDataStream, ValueHolderPtr, DataStreamCmp > WritesMap
Definition: dbwrapper.h:599
Definition: serialize.h:161
std::set< CDataStream, DataStreamCmp > DeletesSet
Definition: dbwrapper.h:600
static bool less(const CDataStream &a, const CDataStream &b)
Definition: dbwrapper.h:561