5 #ifndef BITCOIN_DBWRAPPER_H 6 #define BITCOIN_DBWRAPPER_H 68 bool DestroyDB(
const std::string& path_str);
85 void EraseImpl(std::span<const std::byte> key);
95 template <
typename K,
typename V>
96 void Write(
const K& key,
const V& value)
107 template <
typename K>
128 void SeekImpl(std::span<const std::byte> key);
129 std::span<const std::byte>
GetKeyImpl()
const;
145 template<
typename K>
void Seek(
const K& key) {
158 }
catch (
const std::exception&) {
169 }
catch (
const std::exception&) {
194 std::optional<std::string>
ReadImpl(std::span<const std::byte> key)
const;
195 bool ExistsImpl(std::span<const std::byte> key)
const;
196 size_t EstimateSizeImpl(std::span<const std::byte> key1, std::span<const std::byte> key2)
const;
206 template <
typename K,
typename V>
207 bool Read(
const K& key, V& value)
const 212 std::optional<std::string> strValue{
ReadImpl(ssKey)};
220 }
catch (
const std::exception&) {
226 template <
typename K,
typename V>
227 void Write(
const K& key,
const V& value,
bool fSync =
false)
230 batch.
Write(key, value);
234 template <
typename K>
243 template <
typename K>
244 void Erase(
const K& key,
bool fSync =
false)
275 #endif // BITCOIN_DBWRAPPER_H bool Exists(const K &key) const
dbwrapper_error(const std::string &msg)
void SeekImpl(std::span< const std::byte > key)
fs::path path
Location in the filesystem where leveldb data will be stored.
These should be considered an implementation detail of the specific database.
void EraseImpl(std::span< const std::byte > key)
void reserve(size_type n)
static const size_t DBWRAPPER_MAX_FILE_SIZE
void WriteImpl(std::span< const std::byte > key, DataStream &ssValue)
size_t ApproximateSize() const
Batch of changes queued to be written to a CDBWrapper.
const Obfuscation & GetObfuscation(const CDBWrapper &w)
Work around circular dependency, as well as for testing in dbwrapper_tests.
auto & DBContext() const LIFETIMEBOUND
static const size_t DBWRAPPER_PREALLOC_KEY_SIZE
size_t EstimateSizeImpl(std::span< const std::byte > key1, std::span< const std::byte > key2) const
bool DestroyDB(const std::string &path_str)
const std::unique_ptr< IteratorImpl > m_impl_iter
DBOptions options
Passed-through options.
User-controlled performance and debug options.
CDBIterator(const CDBWrapper &_parent, std::unique_ptr< IteratorImpl > _piter)
Minimal stream for reading from an existing byte array by std::span.
size_t DynamicMemoryUsage() const
const CDBWrapper & parent
std::span< const std::byte > GetKeyImpl() const
void Erase(const K &key, bool fSync=false)
std::span< const std::byte > GetValueImpl() const
void Write(const K &key, const V &value, bool fSync=false)
const CDBWrapper & parent
CDBWrapper & operator=(const CDBWrapper &)=delete
CDBWrapper(const DBParams ¶ms)
void WriteBatch(CDBBatch &batch, bool fSync=false)
static const std::string OBFUSCATION_KEY
obfuscation key storage key, null-prefixed to avoid collisions
Double ended buffer combining vector and stream-like interfaces.
CDBIterator * NewIterator()
Obfuscation m_obfuscation
optional XOR-obfuscation of the database
void Write(const K &key, const V &value)
auto MakeWritableByteSpan(V &&v) noexcept
bool wipe_data
If true, remove all existing data.
bool IsEmpty()
Return true if the database managed by this class contains no entries.
bool Read(const K &key, V &value) const
bool force_compact
Compact database on startup.
bool obfuscate
If true, store data obfuscated via simple XOR.
static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE
std::string m_name
the name of this database
std::unique_ptr< LevelDBContext > m_db_context
holds all leveldb-specific fields of this class
bool ExistsImpl(std::span< const std::byte > key) const
std::optional< std::string > ReadImpl(std::span< const std::byte > key) const
Application-specific storage settings.
CDBBatch(const CDBWrapper &_parent)
size_t cache_bytes
Configures various leveldb cache settings.
const std::unique_ptr< WriteBatchImpl > m_impl_batch
size_t EstimateSize(const K &key_begin, const K &key_end) const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
bool memory_only
If true, use leveldb's memory environment.
#define Assert(val)
Identity function.