Coverage Report

Created: 2026-06-12 16:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/dbwrapper.h
Line
Count
Source
1
// Copyright (c) 2012-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef BITCOIN_DBWRAPPER_H
6
#define BITCOIN_DBWRAPPER_H
7
8
#include <attributes.h>
9
#include <serialize.h>
10
#include <span.h>
11
#include <streams.h>
12
#include <util/byte_units.h>
13
#include <util/check.h>
14
#include <util/fs.h>
15
16
#include <cstddef>
17
#include <exception>
18
#include <memory>
19
#include <optional>
20
#include <stdexcept>
21
#include <string>
22
23
namespace leveldb {
24
class Env;
25
} // namespace leveldb
26
27
static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64;
28
static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024;
29
static const size_t DBWRAPPER_MAX_FILE_SIZE{32_MiB};
30
31
//! User-controlled performance and debug options.
32
struct DBOptions {
33
    //! Compact database on startup.
34
    bool force_compact = false;
35
};
36
37
//! Application-specific storage settings.
38
struct DBParams {
39
    //! Location in the filesystem where leveldb data will be stored.
40
    fs::path path;
41
    //! Configures various leveldb cache settings.
42
    size_t cache_bytes;
43
    //! If true, use leveldb's memory environment.
44
    bool memory_only = false;
45
    //! If true, remove all existing data.
46
    bool wipe_data = false;
47
    //! If true, store data obfuscated via simple XOR. If false, XOR with a
48
    //! zero'd byte array.
49
    bool obfuscate = false;
50
    //! Passed-through options.
51
    DBOptions options{};
52
    //! If non-null, use this as the leveldb::Env instead of the default.
53
    //! Caller retains ownership.
54
    leveldb::Env* testing_env = nullptr;
55
    //! Maximum LevelDB SST file size. Larger values reduce the frequency
56
    //! of compactions but increase their duration.
57
    size_t max_file_size = DBWRAPPER_MAX_FILE_SIZE;
58
};
59
60
class dbwrapper_error : public std::runtime_error
61
{
62
public:
63
0
    explicit dbwrapper_error(const std::string& msg) : std::runtime_error(msg) {}
64
};
65
66
class CDBWrapper;
67
68
/** These should be considered an implementation detail of the specific database.
69
 */
70
namespace dbwrapper_private {
71
72
/** Work around circular dependency, as well as for testing in dbwrapper_tests.
73
 * Database obfuscation should be considered an implementation detail of the
74
 * specific database.
75
 */
76
const Obfuscation& GetObfuscation(const CDBWrapper&);
77
}; // namespace dbwrapper_private
78
79
bool DestroyDB(const std::string& path_str);
80
81
/** Batch of changes queued to be written to a CDBWrapper */
82
class CDBBatch
83
{
84
    friend class CDBWrapper;
85
86
private:
87
    const CDBWrapper &parent;
88
89
    struct WriteBatchImpl;
90
    const std::unique_ptr<WriteBatchImpl> m_impl_batch;
91
92
    DataStream m_key_scratch{};
93
    DataStream m_value_scratch{};
94
95
    void WriteImpl(std::span<const std::byte> key, DataStream& value);
96
    void EraseImpl(std::span<const std::byte> key);
97
98
public:
99
    /**
100
     * @param[in] _parent   CDBWrapper that this batch is to be submitted to
101
     */
102
    explicit CDBBatch(const CDBWrapper& _parent);
103
    ~CDBBatch();
104
    void Clear();
105
106
    template <typename K, typename V>
107
    void Write(const K& key, const V& value)
108
1.63M
    {
109
1.63M
        ScopedDataStreamUsage scoped_key{m_key_scratch}, scoped_value{m_value_scratch};
110
1.63M
        m_key_scratch << key;
111
1.63M
        m_value_scratch << value;
112
1.63M
        WriteImpl(m_key_scratch, m_value_scratch);
113
1.63M
    }
_ZN8CDBBatch5WriteItSt6vectorIhSaIhEEEEvRKT_RKT0_
Line
Count
Source
108
1.63M
    {
109
1.63M
        ScopedDataStreamUsage scoped_key{m_key_scratch}, scoped_value{m_value_scratch};
110
1.63M
        m_key_scratch << key;
111
1.63M
        m_value_scratch << value;
112
1.63M
        WriteImpl(m_key_scratch, m_value_scratch);
113
1.63M
    }
_ZN8CDBBatch5WriteINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE11ObfuscationEEvRKT_RKT0_
Line
Count
Source
108
1.21k
    {
109
1.21k
        ScopedDataStreamUsage scoped_key{m_key_scratch}, scoped_value{m_value_scratch};
110
1.21k
        m_key_scratch << key;
111
1.21k
        m_value_scratch << value;
112
1.21k
        WriteImpl(m_key_scratch, m_value_scratch);
113
1.21k
    }
Unexecuted instantiation: _ZN8CDBBatch5WriteIhhEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteISt4pairIhiEN6kernel14CBlockFileInfoEEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIhiEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteISt4pairIh7uint256E15CDiskBlockIndexEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteISt4pairIhNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEhEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIhSt6vectorI7uint256SaIS2_EEEEvRKT_RKT0_
Unexecuted instantiation: txdb.cpp:_ZN8CDBBatch5WriteIN12_GLOBAL__N_19CoinEntryE4CoinEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIh7uint256EEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIh13CBlockLocatorEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIh11FlatFilePosEEvRKT_RKT0_
Unexecuted instantiation: blockfilterindex.cpp:_ZN8CDBBatch5WriteIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEvRKT_RKT0_
Unexecuted instantiation: blockfilterindex.cpp:_ZN8CDBBatch5WriteIN10index_util9DBHashKeyEN12_GLOBAL__N_15DBValEEEvRKT_RKT0_
Unexecuted instantiation: coinstatsindex.cpp:_ZN8CDBBatch5WriteIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEvRKT_RKT0_
Unexecuted instantiation: coinstatsindex.cpp:_ZN8CDBBatch5WriteIN10index_util9DBHashKeyEN12_GLOBAL__N_15DBValEEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIh10MuHash3072EEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteISt4pairIh7uint256E10CDiskTxPosEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteIA12_cSt4pairImmEEEvRKT_RKT0_
Unexecuted instantiation: _ZN8CDBBatch5WriteI5DBKeyA1_cEEvRKT_RKT0_
114
115
    template <typename K>
116
    void Erase(const K& key)
117
0
    {
118
0
        ScopedDataStreamUsage scoped_key{m_key_scratch};
119
0
        m_key_scratch << key;
120
0
        EraseImpl(m_key_scratch);
121
0
    }
Unexecuted instantiation: _ZN8CDBBatch5EraseItEEvRKT_
Unexecuted instantiation: _ZN8CDBBatch5EraseIhEEvRKT_
Unexecuted instantiation: txdb.cpp:_ZN8CDBBatch5EraseIN12_GLOBAL__N_19CoinEntryEEEvRKT_
Unexecuted instantiation: _ZN8CDBBatch5EraseI5DBKeyEEvRKT_
122
123
    size_t ApproximateSize() const;
124
};
125
126
class CDBIterator
127
{
128
public:
129
    struct IteratorImpl;
130
131
private:
132
    const CDBWrapper &parent;
133
    const std::unique_ptr<IteratorImpl> m_impl_iter;
134
    DataStream m_scratch{};
135
136
    void SeekImpl(std::span<const std::byte> key);
137
    std::span<const std::byte> GetKeyImpl() const;
138
    std::span<const std::byte> GetValueImpl() const;
139
140
public:
141
142
    /**
143
     * @param[in] _parent          Parent CDBWrapper instance.
144
     * @param[in] _piter           The original leveldb iterator.
145
     */
146
    CDBIterator(const CDBWrapper& _parent, std::unique_ptr<IteratorImpl> _piter);
147
    ~CDBIterator();
148
149
    bool Valid() const;
150
151
    void SeekToFirst();
152
153
47.7k
    template<typename K> void Seek(const K& key) {
154
47.7k
        ScopedDataStreamUsage scoped_scratch{m_scratch};
155
47.7k
        m_scratch << key;
156
47.7k
        SeekImpl(m_scratch);
157
47.7k
    }
_ZN11CDBIterator4SeekItEEvRKT_
Line
Count
Source
153
47.7k
    template<typename K> void Seek(const K& key) {
154
47.7k
        ScopedDataStreamUsage scoped_scratch{m_scratch};
155
47.7k
        m_scratch << key;
156
47.7k
        SeekImpl(m_scratch);
157
47.7k
    }
Unexecuted instantiation: _ZN11CDBIterator4SeekISt4pairIh7uint256EEEvRKT_
Unexecuted instantiation: _ZN11CDBIterator4SeekIhEEvRKT_
Unexecuted instantiation: _ZN11CDBIterator4SeekIN10index_util11DBHeightKeyEEEvRKT_
Unexecuted instantiation: _ZN11CDBIterator4SeekISt4pairIhmEEEvRKT_
158
159
    void Next();
160
161
88.4k
    template<typename K> bool GetKey(K& key) {
162
88.4k
        try {
163
88.4k
            SpanReader ssKey{GetKeyImpl()};
164
88.4k
            ssKey >> key;
165
88.4k
        } catch (const std::exception&) {
166
27.8k
            return false;
167
27.8k
        }
168
65.5k
        return true;
169
88.4k
    }
_ZN11CDBIterator6GetKeyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbRT_
Line
Count
Source
161
43.9k
    template<typename K> bool GetKey(K& key) {
162
43.9k
        try {
163
43.9k
            SpanReader ssKey{GetKeyImpl()};
164
43.9k
            ssKey >> key;
165
43.9k
        } catch (const std::exception&) {
166
27.8k
            return false;
167
27.8k
        }
168
18.3k
        return true;
169
43.9k
    }
_ZN11CDBIterator6GetKeyItEEbRT_
Line
Count
Source
161
44.4k
    template<typename K> bool GetKey(K& key) {
162
44.4k
        try {
163
44.4k
            SpanReader ssKey{GetKeyImpl()};
164
44.4k
            ssKey >> key;
165
44.4k
        } catch (const std::exception&) {
166
0
            return false;
167
0
        }
168
47.1k
        return true;
169
44.4k
    }
Unexecuted instantiation: _ZN11CDBIterator6GetKeyISt4pairIh7uint256EEEbRT_
Unexecuted instantiation: txdb.cpp:_ZN11CDBIterator6GetKeyIN12_GLOBAL__N_19CoinEntryEEEbRT_
Unexecuted instantiation: _ZN11CDBIterator6GetKeyIN10index_util11DBHeightKeyEEEbRT_
Unexecuted instantiation: _ZN11CDBIterator6GetKeyI5DBKeyEEbRT_
170
171
47.1k
    template<typename V> bool GetValue(V& value) {
172
47.1k
        try {
173
47.1k
            ScopedDataStreamUsage scoped_scratch{m_scratch};
174
47.1k
            m_scratch.write(GetValueImpl());
175
47.1k
            dbwrapper_private::GetObfuscation(parent)(m_scratch);
176
47.1k
            m_scratch >> value;
177
47.1k
        } catch (const std::exception&) {
178
0
            return false;
179
0
        }
180
46.4k
        return true;
181
47.1k
    }
_ZN11CDBIterator8GetValueISt6vectorIhSaIhEEEEbRT_
Line
Count
Source
171
47.1k
    template<typename V> bool GetValue(V& value) {
172
47.1k
        try {
173
47.1k
            ScopedDataStreamUsage scoped_scratch{m_scratch};
174
47.1k
            m_scratch.write(GetValueImpl());
175
47.1k
            dbwrapper_private::GetObfuscation(parent)(m_scratch);
176
47.1k
            m_scratch >> value;
177
47.1k
        } catch (const std::exception&) {
178
0
            return false;
179
0
        }
180
46.4k
        return true;
181
47.1k
    }
Unexecuted instantiation: _ZN11CDBIterator8GetValueI15CDiskBlockIndexEEbRT_
Unexecuted instantiation: _ZN11CDBIterator8GetValueI4CoinEEbRT_
Unexecuted instantiation: blockfilterindex.cpp:_ZN11CDBIterator8GetValueISt4pairI7uint256N12_GLOBAL__N_15DBValEEEEbRT_
Unexecuted instantiation: coinstatsindex.cpp:_ZN11CDBIterator8GetValueISt4pairI7uint256N12_GLOBAL__N_15DBValEEEEbRT_
182
};
183
184
struct LevelDBContext;
185
186
class CDBWrapper
187
{
188
    friend const Obfuscation& dbwrapper_private::GetObfuscation(const CDBWrapper&);
189
private:
190
    //! holds all leveldb-specific fields of this class
191
    std::unique_ptr<LevelDBContext> m_db_context;
192
193
    //! the name of this database
194
    std::string m_name;
195
196
    //! optional XOR-obfuscation of the database
197
    Obfuscation m_obfuscation;
198
199
    //! obfuscation key storage key, null-prefixed to avoid collisions
200
    inline static const std::string OBFUSCATION_KEY{"\000obfuscate_key", 14}; // explicit size to avoid truncation at leading \0
201
202
    std::optional<std::string> ReadImpl(std::span<const std::byte> key) const;
203
    bool ExistsImpl(std::span<const std::byte> key) const;
204
    size_t EstimateSizeImpl(std::span<const std::byte> key1, std::span<const std::byte> key2) const;
205
8.30M
    auto& DBContext() const LIFETIMEBOUND { return *Assert(m_db_context); }
206
207
public:
208
    CDBWrapper(const DBParams& params);
209
    ~CDBWrapper();
210
211
    CDBWrapper(const CDBWrapper&) = delete;
212
    CDBWrapper& operator=(const CDBWrapper&) = delete;
213
214
    template <typename K, typename V>
215
    bool Read(const K& key, V& value) const
216
4.16M
    {
217
4.16M
        DataStream ssKey{};
218
4.16M
        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
219
4.16M
        ssKey << key;
220
4.16M
        std::optional<std::string> strValue{ReadImpl(ssKey)};
221
4.16M
        if (!strValue) {
  Branch (221:13): [True: 1.11M, False: 3.04M]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 1.55k, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
  Branch (221:13): [True: 0, False: 0]
222
1.11M
            return false;
223
1.11M
        }
224
3.04M
        try {
225
3.04M
            std::span ssValue{MakeWritableByteSpan(*strValue)};
226
3.04M
            m_obfuscation(ssValue);
227
3.04M
            SpanReader{ssValue} >> value;
228
3.04M
        } catch (const std::exception&) {
229
0
            return false;
230
0
        }
231
3.24M
        return true;
232
3.04M
    }
_ZNK10CDBWrapper4ReadItSt6vectorIhSaIhEEEEbRKT_RT0_
Line
Count
Source
216
4.16M
    {
217
4.16M
        DataStream ssKey{};
218
4.16M
        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
219
4.16M
        ssKey << key;
220
4.16M
        std::optional<std::string> strValue{ReadImpl(ssKey)};
221
4.16M
        if (!strValue) {
  Branch (221:13): [True: 1.11M, False: 3.04M]
222
1.11M
            return false;
223
1.11M
        }
224
3.04M
        try {
225
3.04M
            std::span ssValue{MakeWritableByteSpan(*strValue)};
226
3.04M
            m_obfuscation(ssValue);
227
3.04M
            SpanReader{ssValue} >> value;
228
3.04M
        } catch (const std::exception&) {
229
0
            return false;
230
0
        }
231
3.24M
        return true;
232
3.04M
    }
Unexecuted instantiation: dbwrapper.cpp:_ZNK10CDBWrapper4ReadItN12_GLOBAL__N_115FailUnserializeEEEbRKT_RT0_
_ZNK10CDBWrapper4ReadINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE11ObfuscationEEbRKT_RT0_
Line
Count
Source
216
1.55k
    {
217
1.55k
        DataStream ssKey{};
218
1.55k
        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
219
1.55k
        ssKey << key;
220
1.55k
        std::optional<std::string> strValue{ReadImpl(ssKey)};
221
1.55k
        if (!strValue) {
  Branch (221:13): [True: 1.55k, False: 0]
222
1.55k
            return false;
223
1.55k
        }
224
0
        try {
225
0
            std::span ssValue{MakeWritableByteSpan(*strValue)};
226
0
            m_obfuscation(ssValue);
227
0
            SpanReader{ssValue} >> value;
228
0
        } catch (const std::exception&) {
229
0
            return false;
230
0
        }
231
0
        return true;
232
0
    }
Unexecuted instantiation: _ZNK10CDBWrapper4ReadISt4pairIhiEN6kernel14CBlockFileInfoEEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIhiEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadISt4pairIhNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEhEEbRKT_RT0_
Unexecuted instantiation: txdb.cpp:_ZNK10CDBWrapper4ReadIN12_GLOBAL__N_19CoinEntryE4CoinEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIh7uint256EEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIhSt6vectorI7uint256SaIS2_EEEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIh13CBlockLocatorEEbRKT_RT0_
Unexecuted instantiation: blockfilterindex.cpp:_ZNK10CDBWrapper4ReadIN10index_util9DBHashKeyEN12_GLOBAL__N_15DBValEEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIh11FlatFilePosEEbRKT_RT0_
Unexecuted instantiation: blockfilterindex.cpp:_ZNK10CDBWrapper4ReadIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEbRKT_RT0_
Unexecuted instantiation: coinstatsindex.cpp:_ZNK10CDBWrapper4ReadIN10index_util9DBHashKeyEN12_GLOBAL__N_15DBValEEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIh10MuHash3072EEbRKT_RT0_
Unexecuted instantiation: coinstatsindex.cpp:_ZNK10CDBWrapper4ReadIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEbRKT_RT0_
Unexecuted instantiation: coinstatsindex.cpp:_ZNK10CDBWrapper4ReadIN10index_util9DBHashKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadISt4pairIh7uint256E10CDiskTxPosEEbRKT_RT0_
Unexecuted instantiation: _ZNK10CDBWrapper4ReadIA12_cSt4pairImmEEEbRKT_RT0_
233
234
    template <typename K, typename V>
235
    void Write(const K& key, const V& value, bool fSync = false)
236
1.21k
    {
237
1.21k
        CDBBatch batch(*this);
238
1.21k
        batch.Write(key, value);
239
1.21k
        WriteBatch(batch, fSync);
240
1.21k
    }
Unexecuted instantiation: _ZN10CDBWrapper5WriteItSt6vectorIhSaIhEEEEvRKT_RKT0_b
_ZN10CDBWrapper5WriteINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE11ObfuscationEEvRKT_RKT0_b
Line
Count
Source
236
1.21k
    {
237
1.21k
        CDBBatch batch(*this);
238
1.21k
        batch.Write(key, value);
239
1.21k
        WriteBatch(batch, fSync);
240
1.21k
    }
Unexecuted instantiation: _ZN10CDBWrapper5WriteIhhEEvRKT_RKT0_b
Unexecuted instantiation: _ZN10CDBWrapper5WriteISt4pairIhNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEhEEvRKT_RKT0_b
Unexecuted instantiation: blockfilterindex.cpp:_ZN10CDBWrapper5WriteIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEvRKT_RKT0_b
Unexecuted instantiation: coinstatsindex.cpp:_ZN10CDBWrapper5WriteIN10index_util11DBHeightKeyESt4pairI7uint256N12_GLOBAL__N_15DBValEEEEvRKT_RKT0_b
Unexecuted instantiation: _ZN10CDBWrapper5WriteIA12_cSt4pairImmEEEvRKT_RKT0_b
241
242
    template <typename K>
243
    bool Exists(const K& key) const
244
6.89k
    {
245
6.89k
        DataStream ssKey{};
246
6.89k
        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
247
6.89k
        ssKey << key;
248
6.89k
        return ExistsImpl(ssKey);
249
6.89k
    }
_ZNK10CDBWrapper6ExistsItEEbRKT_
Line
Count
Source
244
6.89k
    {
245
6.89k
        DataStream ssKey{};
246
6.89k
        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
247
6.89k
        ssKey << key;
248
6.89k
        return ExistsImpl(ssKey);
249
6.89k
    }
Unexecuted instantiation: _ZNK10CDBWrapper6ExistsIhEEbRKT_
Unexecuted instantiation: txdb.cpp:_ZNK10CDBWrapper6ExistsIN12_GLOBAL__N_19CoinEntryEEEbRKT_
250
251
    template <typename K>
252
    void Erase(const K& key, bool fSync = false)
253
0
    {
254
0
        CDBBatch batch(*this);
255
0
        batch.Erase(key);
256
0
        WriteBatch(batch, fSync);
257
0
    }
Unexecuted instantiation: _ZN10CDBWrapper5EraseItEEvRKT_b
Unexecuted instantiation: _ZN10CDBWrapper5EraseIhEEvRKT_b
258
259
    void WriteBatch(CDBBatch& batch, bool fSync = false);
260
261
    // Get an estimate of LevelDB memory usage (in bytes).
262
    size_t DynamicMemoryUsage() const;
263
264
    CDBIterator* NewIterator();
265
266
    /**
267
     * Return true if the database managed by this class contains no entries.
268
     */
269
    bool IsEmpty();
270
271
    template<typename K>
272
    size_t EstimateSize(const K& key_begin, const K& key_end) const
273
0
    {
274
0
        DataStream ssKey1{}, ssKey2{};
275
0
        ssKey1.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
276
0
        ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
277
0
        ssKey1 << key_begin;
278
0
        ssKey2 << key_end;
279
0
        return EstimateSizeImpl(ssKey1, ssKey2);
280
0
    }
Unexecuted instantiation: _ZNK10CDBWrapper12EstimateSizeItEEmRKT_S3_
Unexecuted instantiation: _ZNK10CDBWrapper12EstimateSizeIhEEmRKT_S3_
281
};
282
283
#endif // BITCOIN_DBWRAPPER_H