Coverage Report

Created: 2025-06-10 13:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/bitcoin/src/streams.h
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#ifndef BITCOIN_STREAMS_H
7
#define BITCOIN_STREAMS_H
8
9
#include <serialize.h>
10
#include <span.h>
11
#include <support/allocators/zeroafterfree.h>
12
#include <util/overflow.h>
13
14
#include <algorithm>
15
#include <assert.h>
16
#include <cstddef>
17
#include <cstdio>
18
#include <ios>
19
#include <limits>
20
#include <optional>
21
#include <stdint.h>
22
#include <string.h>
23
#include <string>
24
#include <utility>
25
#include <vector>
26
27
namespace util {
28
inline void Xor(std::span<std::byte> write, std::span<const std::byte> key, size_t key_offset = 0)
29
16.5M
{
30
16.5M
    if (key.size() == 0) {
  Branch (30:9): [True: 0, False: 16.5M]
31
0
        return;
32
0
    }
33
16.5M
    key_offset %= key.size();
34
35
148G
    for (size_t i = 0, j = key_offset; i != write.size(); i++) {
  Branch (35:40): [True: 148G, False: 16.5M]
36
148G
        write[i] ^= key[j++];
37
38
        // This potentially acts on very many bytes of data, so it's
39
        // important that we calculate `j`, i.e. the `key` index in this
40
        // way instead of doing a %, which would effectively be a division
41
        // for each byte Xor'd -- much slower than need be.
42
148G
        if (j == key.size())
  Branch (42:13): [True: 18.5G, False: 129G]
43
18.5G
            j = 0;
44
148G
    }
45
16.5M
}
46
} // namespace util
47
48
/* Minimal stream for overwriting and/or appending to an existing byte vector
49
 *
50
 * The referenced vector will grow as necessary
51
 */
52
class VectorWriter
53
{
54
public:
55
/*
56
 * @param[in]  vchDataIn  Referenced byte vector to overwrite/append
57
 * @param[in]  nPosIn Starting position. Vector index where writes should start. The vector will initially
58
 *                    grow as necessary to max(nPosIn, vec.size()). So to append, use vec.size().
59
*/
60
28.1M
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn) : vchData{vchDataIn}, nPos{nPosIn}
61
28.1M
    {
62
28.1M
        if(nPos > vchData.size())
  Branch (62:12): [True: 0, False: 28.1M]
63
0
            vchData.resize(nPos);
64
28.1M
    }
65
/*
66
 * (other params same as above)
67
 * @param[in]  args  A list of items to serialize starting at nPosIn.
68
*/
69
    template <typename... Args>
70
25.5M
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
25.5M
    {
72
25.5M
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
25.5M
    }
VectorWriter::VectorWriter<CMessageHeader&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, CMessageHeader&)
Line
Count
Source
70
12.9M
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
12.9M
    {
72
12.9M
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
12.9M
    }
VectorWriter::VectorWriter<bool, unsigned long const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, bool&&, unsigned long const&)
Line
Count
Source
70
102k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
102k
    {
72
102k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
102k
    }
VectorWriter::VectorWriter<CBlockHeaderAndShortTxIDs const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, CBlockHeaderAndShortTxIDs const&)
Line
Count
Source
70
2.40k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
2.40k
    {
72
2.40k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
2.40k
    }
VectorWriter::VectorWriter<std::vector<CInv, std::allocator<CInv> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, std::vector<CInv, std::allocator<CInv> >&)
Line
Count
Source
70
9.98M
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
9.98M
    {
72
9.98M
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
9.98M
    }
VectorWriter::VectorWriter<int const&, unsigned long&, long const&, unsigned long&, ParamsWrapper<CNetAddr::SerParams, CService>, unsigned long&, ParamsWrapper<CNetAddr::SerParams, CService>, unsigned long&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int const&, bool const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, int const&, unsigned long&, long const&, unsigned long&, ParamsWrapper<CNetAddr::SerParams, CService>&&, unsigned long&, ParamsWrapper<CNetAddr::SerParams, CService>&&, unsigned long&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int const&, bool const&)
Line
Count
Source
70
88.7k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
88.7k
    {
72
88.7k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
88.7k
    }
VectorWriter::VectorWriter<unsigned int const&, unsigned long const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, unsigned int const&, unsigned long const&)
Line
Count
Source
70
88.7k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
88.7k
    {
72
88.7k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
88.7k
    }
Unexecuted instantiation: VectorWriter::VectorWriter<std::array<std::byte, 168ul> const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, std::array<std::byte, 168ul> const&)
VectorWriter::VectorWriter<CBlockLocator const&, uint256>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, CBlockLocator const&, uint256&&)
Line
Count
Source
70
91.6k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
91.6k
    {
72
91.6k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
91.6k
    }
VectorWriter::VectorWriter<ParamsWrapper<TransactionSerParams, CTransaction const> >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, ParamsWrapper<TransactionSerParams, CTransaction const>&&)
Line
Count
Source
70
2.07k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
2.07k
    {
72
2.07k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
2.07k
    }
VectorWriter::VectorWriter<std::span<unsigned char, 18446744073709551615ul> >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, std::span<unsigned char, 18446744073709551615ul>&&)
Line
Count
Source
70
2.00k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
2.00k
    {
72
2.00k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
2.00k
    }
VectorWriter::VectorWriter<ParamsWrapper<TransactionSerParams, CBlock const> >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, ParamsWrapper<TransactionSerParams, CBlock const>&&)
Line
Count
Source
70
3.31k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
3.31k
    {
72
3.31k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
3.31k
    }
Unexecuted instantiation: VectorWriter::VectorWriter<CMerkleBlock&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, CMerkleBlock&)
VectorWriter::VectorWriter<CBlockHeaderAndShortTxIDs&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, CBlockHeaderAndShortTxIDs&)
Line
Count
Source
70
526
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
526
    {
72
526
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
526
    }
Unexecuted instantiation: VectorWriter::VectorWriter<BlockTransactions&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, BlockTransactions&)
Unexecuted instantiation: VectorWriter::VectorWriter<std::vector<CBlockHeader, std::allocator<CBlockHeader> > >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, std::vector<CBlockHeader, std::allocator<CBlockHeader> >&&)
VectorWriter::VectorWriter<ParamsWrapper<TransactionSerParams, std::vector<CBlock, std::allocator<CBlock> > > >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, ParamsWrapper<TransactionSerParams, std::vector<CBlock, std::allocator<CBlock> > >&&)
Line
Count
Source
70
103
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
103
    {
72
103
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
103
    }
Unexecuted instantiation: VectorWriter::VectorWriter<BlockTransactionsRequest&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, BlockTransactionsRequest&)
VectorWriter::VectorWriter<unsigned long&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, unsigned long&)
Line
Count
Source
70
2.10M
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
2.10M
    {
72
2.10M
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
2.10M
    }
Unexecuted instantiation: VectorWriter::VectorWriter<BlockFilter const&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, BlockFilter const&)
Unexecuted instantiation: VectorWriter::VectorWriter<unsigned char&, uint256, uint256&, std::vector<uint256, std::allocator<uint256> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, unsigned char&, uint256&&, uint256&, std::vector<uint256, std::allocator<uint256> >&)
Unexecuted instantiation: VectorWriter::VectorWriter<unsigned char&, uint256, std::vector<uint256, std::allocator<uint256> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, unsigned char&, uint256&&, std::vector<uint256, std::allocator<uint256> >&)
VectorWriter::VectorWriter<ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress> > > >(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress> > >&&)
Line
Count
Source
70
145
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
145
    {
72
145
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
145
    }
VectorWriter::VectorWriter<long&>(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, long&)
Line
Count
Source
70
88.7k
    VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn}
71
88.7k
    {
72
88.7k
        ::SerializeMany(*this, std::forward<Args>(args)...);
73
88.7k
    }
74
    void write(std::span<const std::byte> src)
75
95.7M
    {
76
95.7M
        assert(nPos <= vchData.size());
  Branch (76:9): [True: 95.7M, False: 18.4E]
77
95.7M
        size_t nOverwrite = std::min(src.size(), vchData.size() - nPos);
78
95.7M
        if (nOverwrite) {
  Branch (78:13): [True: 0, False: 95.7M]
79
0
            memcpy(vchData.data() + nPos, src.data(), nOverwrite);
80
0
        }
81
95.7M
        if (nOverwrite < src.size()) {
  Branch (81:13): [True: 95.7M, False: 41]
82
95.7M
            vchData.insert(vchData.end(), UCharCast(src.data()) + nOverwrite, UCharCast(src.data() + src.size()));
83
95.7M
        }
84
95.7M
        nPos += src.size();
85
95.7M
    }
86
    template <typename T>
87
    VectorWriter& operator<<(const T& obj)
88
17.1M
    {
89
17.1M
        ::Serialize(*this, obj);
90
17.1M
        return (*this);
91
17.1M
    }
VectorWriter& VectorWriter::operator<< <std::span<unsigned char const, 32ul> >(std::span<unsigned char const, 32ul> const&)
Line
Count
Source
88
10.4M
    {
89
10.4M
        ::Serialize(*this, obj);
90
10.4M
        return (*this);
91
10.4M
    }
VectorWriter& VectorWriter::operator<< <unsigned char>(unsigned char const&)
Line
Count
Source
88
6.70M
    {
89
6.70M
        ::Serialize(*this, obj);
90
6.70M
        return (*this);
91
6.70M
    }
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <uint256>(uint256 const&)
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <std::vector<unsigned char, std::allocator<unsigned char> > >(std::vector<unsigned char, std::allocator<unsigned char> > const&)
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <std::set<uint256, std::less<uint256>, std::allocator<uint256> > >(std::set<uint256, std::less<uint256>, std::allocator<uint256> > const&)
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <unsigned char [4]>(unsigned char const (&) [4])
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <unsigned int>(unsigned int const&)
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <std::span<unsigned char const, 18446744073709551615ul> >(std::span<unsigned char const, 18446744073709551615ul> const&)
Unexecuted instantiation: VectorWriter& VectorWriter::operator<< <int>(int const&)
92
93
private:
94
    std::vector<unsigned char>& vchData;
95
    size_t nPos;
96
};
97
98
/** Minimal stream for reading from an existing byte array by std::span.
99
 */
100
class SpanReader
101
{
102
private:
103
    std::span<const unsigned char> m_data;
104
105
public:
106
    /**
107
     * @param[in]  data Referenced byte vector to overwrite/append
108
     */
109
23.6k
    explicit SpanReader(std::span<const unsigned char> data) : m_data{data} {}
110
111
    template<typename T>
112
    SpanReader& operator>>(T&& obj)
113
23.6k
    {
114
23.6k
        ::Unserialize(*this, obj);
115
23.6k
        return (*this);
116
23.6k
    }
SpanReader& SpanReader::operator>><ParamsWrapper<TransactionSerParams, CBlock> >(ParamsWrapper<TransactionSerParams, CBlock>&&)
Line
Count
Source
113
23.6k
    {
114
23.6k
        ::Unserialize(*this, obj);
115
23.6k
        return (*this);
116
23.6k
    }
Unexecuted instantiation: SpanReader& SpanReader::operator>><CScript&>(CScript&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><std::vector<std::vector<unsigned char, std::allocator<unsigned char> >, std::allocator<std::vector<unsigned char, std::allocator<unsigned char> > > >&>(std::vector<std::vector<unsigned char, std::allocator<unsigned char> >, std::allocator<std::vector<unsigned char, std::allocator<unsigned char> > > >&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><unsigned char&>(unsigned char&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><std::vector<unsigned char, std::allocator<unsigned char> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><XOnlyPubKey&>(XOnlyPubKey&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><uint256&>(uint256&)
Unexecuted instantiation: SpanReader& SpanReader::operator>><std::span<std::byte, 33ul> >(std::span<std::byte, 33ul>&&)
117
118
0
    size_t size() const { return m_data.size(); }
119
0
    bool empty() const { return m_data.empty(); }
120
121
    void read(std::span<std::byte> dst)
122
1.21M
    {
123
1.21M
        if (dst.size() == 0) {
  Branch (123:13): [True: 0, False: 1.21M]
124
0
            return;
125
0
        }
126
127
        // Read from the beginning of the buffer
128
1.21M
        if (dst.size() > m_data.size()) {
  Branch (128:13): [True: 0, False: 1.21M]
129
0
            throw std::ios_base::failure("SpanReader::read(): end of data");
130
0
        }
131
1.21M
        memcpy(dst.data(), m_data.data(), dst.size());
132
1.21M
        m_data = m_data.subspan(dst.size());
133
1.21M
    }
134
135
    void ignore(size_t n)
136
0
    {
137
0
        m_data = m_data.subspan(n);
138
0
    }
139
};
140
141
/** Double ended buffer combining vector and stream-like interfaces.
142
 *
143
 * >> and << read and write unformatted data using the above serialization templates.
144
 * Fills with data in linear time; some stringstream implementations take N^2 time.
145
 */
146
class DataStream
147
{
148
protected:
149
    using vector_type = SerializeData;
150
    vector_type vch;
151
    vector_type::size_type m_read_pos{0};
152
153
public:
154
    typedef vector_type::allocator_type   allocator_type;
155
    typedef vector_type::size_type        size_type;
156
    typedef vector_type::difference_type  difference_type;
157
    typedef vector_type::reference        reference;
158
    typedef vector_type::const_reference  const_reference;
159
    typedef vector_type::value_type       value_type;
160
    typedef vector_type::iterator         iterator;
161
    typedef vector_type::const_iterator   const_iterator;
162
    typedef vector_type::reverse_iterator reverse_iterator;
163
164
14.5M
    explicit DataStream() = default;
165
392
    explicit DataStream(std::span<const uint8_t> sp) : DataStream{std::as_bytes(sp)} {}
166
34.1k
    explicit DataStream(std::span<const value_type> sp) : vch(sp.data(), sp.data() + sp.size()) {}
167
168
    std::string str() const
169
0
    {
170
0
        return std::string{UCharCast(data()), UCharCast(data() + size())};
171
0
    }
172
173
174
    //
175
    // Vector subset
176
    //
177
0
    const_iterator begin() const                     { return vch.begin() + m_read_pos; }
178
4.44M
    iterator begin()                                 { return vch.begin() + m_read_pos; }
179
0
    const_iterator end() const                       { return vch.end(); }
180
2.22M
    iterator end()                                   { return vch.end(); }
181
38.6M
    size_type size() const                           { return vch.size() - m_read_pos; }
182
565k
    bool empty() const                               { return vch.size() == m_read_pos; }
183
10.9M
    void resize(size_type n, value_type c = value_type{}) { vch.resize(n + m_read_pos, c); }
184
20.5M
    void reserve(size_type n)                        { vch.reserve(n + m_read_pos); }
185
0
    const_reference operator[](size_type pos) const  { return vch[pos + m_read_pos]; }
186
10.9M
    reference operator[](size_type pos)              { return vch[pos + m_read_pos]; }
187
25.0M
    void clear()                                     { vch.clear(); m_read_pos = 0; }
188
27.6M
    value_type* data()                               { return vch.data() + m_read_pos; }
189
449
    const value_type* data() const                   { return vch.data() + m_read_pos; }
190
191
    inline void Compact()
192
0
    {
193
0
        vch.erase(vch.begin(), vch.begin() + m_read_pos);
194
0
        m_read_pos = 0;
195
0
    }
196
197
    bool Rewind(std::optional<size_type> n = std::nullopt)
198
0
    {
199
0
        // Total rewind if no size is passed
200
0
        if (!n) {
201
0
            m_read_pos = 0;
202
0
            return true;
203
0
        }
204
0
        // Rewind by n characters if the buffer hasn't been compacted yet
205
0
        if (*n > m_read_pos)
206
0
            return false;
207
0
        m_read_pos -= *n;
208
0
        return true;
209
0
    }
210
211
212
    //
213
    // Stream subset
214
    //
215
392
    bool eof() const             { return size() == 0; }
216
366
    int in_avail() const         { return size(); }
217
218
    void read(std::span<value_type> dst)
219
98.4M
    {
220
98.4M
        if (dst.size() == 0) return;
  Branch (220:13): [True: 0, False: 98.4M]
221
222
        // Read from the beginning of the buffer
223
98.4M
        auto next_read_pos{CheckedAdd(m_read_pos, dst.size())};
224
98.4M
        if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) {
  Branch (224:13): [True: 913, False: 98.4M]
  Branch (224:43): [True: 3.65k, False: 98.4M]
225
4.11k
            throw std::ios_base::failure("DataStream::read(): end of data");
226
4.11k
        }
227
98.4M
        memcpy(dst.data(), &vch[m_read_pos], dst.size());
228
98.4M
        if (next_read_pos.value() == vch.size()) {
  Branch (228:13): [True: 10.9M, False: 87.5M]
229
10.9M
            m_read_pos = 0;
230
10.9M
            vch.clear();
231
10.9M
            return;
232
10.9M
        }
233
87.5M
        m_read_pos = next_read_pos.value();
234
87.5M
    }
235
236
    void ignore(size_t num_ignore)
237
178k
    {
238
        // Ignore from the beginning of the buffer
239
178k
        auto next_read_pos{CheckedAdd(m_read_pos, num_ignore)};
240
178k
        if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) {
  Branch (240:13): [True: 0, False: 178k]
  Branch (240:43): [True: 371, False: 177k]
241
371
            throw std::ios_base::failure("DataStream::ignore(): end of data");
242
371
        }
243
177k
        if (next_read_pos.value() == vch.size()) {
  Branch (243:13): [True: 22, False: 177k]
244
22
            m_read_pos = 0;
245
22
            vch.clear();
246
22
            return;
247
22
        }
248
177k
        m_read_pos = next_read_pos.value();
249
177k
    }
250
251
    void write(std::span<const value_type> src)
252
122M
    {
253
        // Write to the end of the buffer
254
122M
        vch.insert(vch.end(), src.begin(), src.end());
255
122M
    }
256
257
    template<typename T>
258
    DataStream& operator<<(const T& obj)
259
58.5M
    {
260
58.5M
        ::Serialize(*this, obj);
261
58.5M
        return (*this);
262
58.5M
    }
DataStream& DataStream::operator<< <std::pair<unsigned char, int> >(std::pair<unsigned char, int> const&)
Line
Count
Source
259
34.8k
    {
260
34.8k
        ::Serialize(*this, obj);
261
34.8k
        return (*this);
262
34.8k
    }
DataStream& DataStream::operator<< <unsigned char>(unsigned char const&)
Line
Count
Source
259
330k
    {
260
330k
        ::Serialize(*this, obj);
261
330k
        return (*this);
262
330k
    }
DataStream& DataStream::operator<< <CBlockFileInfo>(CBlockFileInfo const&)
Line
Count
Source
259
12.6k
    {
260
12.6k
        ::Serialize(*this, obj);
261
12.6k
        return (*this);
262
12.6k
    }
DataStream& DataStream::operator<< <int>(int const&)
Line
Count
Source
259
51.3k
    {
260
51.3k
        ::Serialize(*this, obj);
261
51.3k
        return (*this);
262
51.3k
    }
DataStream& DataStream::operator<< <std::pair<unsigned char, uint256> >(std::pair<unsigned char, uint256> const&)
Line
Count
Source
259
2.27M
    {
260
2.27M
        ::Serialize(*this, obj);
261
2.27M
        return (*this);
262
2.27M
    }
DataStream& DataStream::operator<< <std::span<unsigned char const, 32ul> >(std::span<unsigned char const, 32ul> const&)
Line
Count
Source
259
26.5M
    {
260
26.5M
        ::Serialize(*this, obj);
261
26.5M
        return (*this);
262
26.5M
    }
DataStream& DataStream::operator<< <CDiskBlockIndex>(CDiskBlockIndex const&)
Line
Count
Source
259
2.25M
    {
260
2.25M
        ::Serialize(*this, obj);
261
2.25M
        return (*this);
262
2.25M
    }
DataStream& DataStream::operator<< <std::pair<unsigned char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(std::pair<unsigned char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)
Line
Count
Source
259
11.0k
    {
260
11.0k
        ::Serialize(*this, obj);
261
11.0k
        return (*this);
262
11.0k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> const> >(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> const> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <BlockFilter>(BlockFilter const&)
DataStream& DataStream::operator<< <uint256>(uint256 const&)
Line
Count
Source
259
117k
    {
260
117k
        ::Serialize(*this, obj);
261
117k
        return (*this);
262
117k
    }
DataStream& DataStream::operator<< <std::vector<unsigned char, std::allocator<unsigned char> > >(std::vector<unsigned char, std::allocator<unsigned char> > const&)
Line
Count
Source
259
188k
    {
260
188k
        ::Serialize(*this, obj);
261
188k
        return (*this);
262
188k
    }
DataStream& DataStream::operator<< <CBlockHeader>(CBlockHeader const&)
Line
Count
Source
259
2.22M
    {
260
2.22M
        ::Serialize(*this, obj);
261
2.22M
        return (*this);
262
2.22M
    }
DataStream& DataStream::operator<< <std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
Line
Count
Source
259
506k
    {
260
506k
        ::Serialize(*this, obj);
261
506k
        return (*this);
262
506k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <std::vector<CCoin, std::allocator<CCoin> > >(std::vector<CCoin, std::allocator<CCoin> > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <ParamsWrapper<TransactionSerParams, CBlock const> >(ParamsWrapper<TransactionSerParams, CBlock const> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <PartiallySignedTransaction>(PartiallySignedTransaction const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <unsigned char [5]>(unsigned char const (&) [5])
Unexecuted instantiation: DataStream& DataStream::operator<< <unsigned char [4]>(unsigned char const (&) [4])
Unexecuted instantiation: DataStream& DataStream::operator<< <unsigned int>(unsigned int const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <PSBTInput>(PSBTInput const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <CScript>(CScript const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <PSBTOutput>(PSBTOutput const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <ParamsWrapper<TransactionSerParams, CMutableTransaction> >(ParamsWrapper<TransactionSerParams, CMutableTransaction> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <CMerkleBlock>(CMerkleBlock const&)
txdb.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::CoinEntry>((anonymous namespace)::CoinEntry const&)
Line
Count
Source
259
7.09M
    {
260
7.09M
        ::Serialize(*this, obj);
261
7.09M
        return (*this);
262
7.09M
    }
DataStream& DataStream::operator<< <std::vector<uint256, std::allocator<uint256> > >(std::vector<uint256, std::allocator<uint256> > const&)
Line
Count
Source
259
29.2k
    {
260
29.2k
        ::Serialize(*this, obj);
261
29.2k
        return (*this);
262
29.2k
    }
DataStream& DataStream::operator<< <Coin>(Coin const&)
Line
Count
Source
259
2.22M
    {
260
2.22M
        ::Serialize(*this, obj);
261
2.22M
        return (*this);
262
2.22M
    }
DataStream& DataStream::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&)
Line
Count
Source
259
2.22M
    {
260
2.22M
        ::Serialize(*this, obj);
261
2.22M
        return (*this);
262
2.22M
    }
DataStream& DataStream::operator<< <std::span<unsigned char, 18446744073709551615ul> >(std::span<unsigned char, 18446744073709551615ul> const&)
Line
Count
Source
259
570
    {
260
570
        ::Serialize(*this, obj);
261
570
        return (*this);
262
570
    }
DataStream& DataStream::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&)
Line
Count
Source
259
2.22M
    {
260
2.22M
        ::Serialize(*this, obj);
261
2.22M
        return (*this);
262
2.22M
    }
DataStream& DataStream::operator<< <std::span<unsigned char const, 18446744073709551615ul> >(std::span<unsigned char const, 18446744073709551615ul> const&)
Line
Count
Source
259
2.31M
    {
260
2.31M
        ::Serialize(*this, obj);
261
2.31M
        return (*this);
262
2.31M
    }
DataStream& DataStream::operator<< <unsigned long>(unsigned long const&)
Line
Count
Source
259
2.32M
    {
260
2.32M
        ::Serialize(*this, obj);
261
2.32M
        return (*this);
262
2.32M
    }
DataStream& DataStream::operator<< <CBlockLocator>(CBlockLocator const&)
Line
Count
Source
259
72.8k
    {
260
72.8k
        ::Serialize(*this, obj);
261
72.8k
        return (*this);
262
72.8k
    }
blockfilterindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBHeightKey>((anonymous namespace)::DBHeightKey const&)
Line
Count
Source
259
2.24M
    {
260
2.24M
        ::Serialize(*this, obj);
261
2.24M
        return (*this);
262
2.24M
    }
blockfilterindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBHashKey>((anonymous namespace)::DBHashKey const&)
Line
Count
Source
259
6.51k
    {
260
6.51k
        ::Serialize(*this, obj);
261
6.51k
        return (*this);
262
6.51k
    }
blockfilterindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBVal>((anonymous namespace)::DBVal const&)
Line
Count
Source
259
6.51k
    {
260
6.51k
        ::Serialize(*this, obj);
261
6.51k
        return (*this);
262
6.51k
    }
DataStream& DataStream::operator<< <FlatFilePos>(FlatFilePos const&)
Line
Count
Source
259
23.2k
    {
260
23.2k
        ::Serialize(*this, obj);
261
23.2k
        return (*this);
262
23.2k
    }
blockfilterindex.cpp:DataStream& DataStream::operator<< <std::pair<uint256, (anonymous namespace)::DBVal> >(std::pair<uint256, (anonymous namespace)::DBVal> const&)
Line
Count
Source
259
2.23M
    {
260
2.23M
        ::Serialize(*this, obj);
261
2.23M
        return (*this);
262
2.23M
    }
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBHeightKey>((anonymous namespace)::DBHeightKey const&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBHashKey>((anonymous namespace)::DBHashKey const&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator<< <(anonymous namespace)::DBVal>((anonymous namespace)::DBVal const&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator<< <std::pair<uint256, (anonymous namespace)::DBVal> >(std::pair<uint256, (anonymous namespace)::DBVal> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <MuHash3072>(MuHash3072 const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <CDiskTxPos>(CDiskTxPos const&)
DataStream& DataStream::operator<< <COutPoint>(COutPoint const&)
Line
Count
Source
259
449
    {
260
449
        ::Serialize(*this, obj);
261
449
        return (*this);
262
449
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <CTxOut>(CTxOut const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::span<std::byte const, 18446744073709551615ul> >(std::span<std::byte const, 18446744073709551615ul> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, transaction_identifier<false> > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, transaction_identifier<false> > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <wallet::CWalletTx>(wallet::CWalletTx const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >(std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <bool>(bool const&)
DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256> const&)
Line
Count
Source
259
266k
    {
260
266k
        ::Serialize(*this, obj);
261
266k
        return (*this);
262
266k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, CPubKey> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, CPubKey> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <wallet::CKeyMetadata>(wallet::CKeyMetadata const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::span<unsigned char const, 20ul> >(std::span<unsigned char const, 20ul> const&)
DataStream& DataStream::operator<< <std::pair<std::vector<unsigned char, secure_allocator<unsigned char> >, uint256> >(std::pair<std::vector<unsigned char, secure_allocator<unsigned char> >, uint256> const&)
Line
Count
Source
259
88.7k
    {
260
88.7k
        ::Serialize(*this, obj);
261
88.7k
        return (*this);
262
88.7k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, uint256> >(std::pair<std::vector<unsigned char, std::allocator<unsigned char> >, uint256> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <wallet::CMasterKey>(wallet::CMasterKey const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, CScript> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, CScript> const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <long>(long const&)
DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char> >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned char> const&)
Line
Count
Source
259
88.7k
    {
260
88.7k
        ::Serialize(*this, obj);
261
88.7k
        return (*this);
262
88.7k
    }
DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<uint256, CPubKey> > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<uint256, CPubKey> > const&)
Line
Count
Source
259
88.7k
    {
260
88.7k
        ::Serialize(*this, obj);
261
88.7k
        return (*this);
262
88.7k
    }
DataStream& DataStream::operator<< <wallet::WalletDescriptor>(wallet::WalletDescriptor const&)
Line
Count
Source
259
266k
    {
260
266k
        ::Serialize(*this, obj);
261
266k
        return (*this);
262
266k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256>, std::pair<unsigned int, unsigned int> > >(std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256>, std::pair<unsigned int, unsigned int> > const&)
DataStream& DataStream::operator<< <std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256>, unsigned int> >(std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, uint256>, unsigned int> const&)
Line
Count
Source
259
177k
    {
260
177k
        ::Serialize(*this, obj);
261
177k
        return (*this);
262
177k
    }
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<transaction_identifier<false>, unsigned int> > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<transaction_identifier<false>, unsigned int> > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)
Unexecuted instantiation: DataStream& DataStream::operator<< <ParamsWrapper<TransactionSerParams, CTransaction const> >(ParamsWrapper<TransactionSerParams, CTransaction const> const&)
263
264
    template<typename T>
265
    DataStream& operator>>(T&& obj)
266
11.6M
    {
267
11.6M
        ::Unserialize(*this, obj);
268
11.6M
        return (*this);
269
11.6M
    }
DataStream& DataStream::operator>><CMessageHeader&>(CMessageHeader&)
Line
Count
Source
266
5.52M
    {
267
5.52M
        ::Unserialize(*this, obj);
268
5.52M
        return (*this);
269
5.52M
    }
DataStream& DataStream::operator>><int&>(int&)
Line
Count
Source
266
177k
    {
267
177k
        ::Unserialize(*this, obj);
268
177k
        return (*this);
269
177k
    }
DataStream& DataStream::operator>><Wrapper<CustomUintFormatter<8, false>, ServiceFlags&> >(Wrapper<CustomUintFormatter<8, false>, ServiceFlags&>&&)
Line
Count
Source
266
88.7k
    {
267
88.7k
        ::Unserialize(*this, obj);
268
88.7k
        return (*this);
269
88.7k
    }
DataStream& DataStream::operator>><long&>(long&)
Line
Count
Source
266
88.9k
    {
267
88.9k
        ::Unserialize(*this, obj);
268
88.9k
        return (*this);
269
88.9k
    }
DataStream& DataStream::operator>><ParamsWrapper<CNetAddr::SerParams, CService> >(ParamsWrapper<CNetAddr::SerParams, CService>&&)
Line
Count
Source
266
88.7k
    {
267
88.7k
        ::Unserialize(*this, obj);
268
88.7k
        return (*this);
269
88.7k
    }
DataStream& DataStream::operator>><unsigned long&>(unsigned long&)
Line
Count
Source
266
2.19M
    {
267
2.19M
        ::Unserialize(*this, obj);
268
2.19M
        return (*this);
269
2.19M
    }
DataStream& DataStream::operator>><Wrapper<LimitedStringFormatter<256ul>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&> >(Wrapper<LimitedStringFormatter<256ul>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>&&)
Line
Count
Source
266
88.7k
    {
267
88.7k
        ::Unserialize(*this, obj);
268
88.7k
        return (*this);
269
88.7k
    }
DataStream& DataStream::operator>><bool&>(bool&)
Line
Count
Source
266
177k
    {
267
177k
        ::Unserialize(*this, obj);
268
177k
        return (*this);
269
177k
    }
DataStream& DataStream::operator>><unsigned int&>(unsigned int&)
Line
Count
Source
266
492
    {
267
492
        ::Unserialize(*this, obj);
268
492
        return (*this);
269
492
    }
DataStream& DataStream::operator>><ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress> > > >(ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress> > >&&)
Line
Count
Source
266
4.35k
    {
267
4.35k
        ::Unserialize(*this, obj);
268
4.35k
        return (*this);
269
4.35k
    }
DataStream& DataStream::operator>><std::vector<CInv, std::allocator<CInv> >&>(std::vector<CInv, std::allocator<CInv> >&)
Line
Count
Source
266
471k
    {
267
471k
        ::Unserialize(*this, obj);
268
471k
        return (*this);
269
471k
    }
DataStream& DataStream::operator>><CBlockLocator&>(CBlockLocator&)
Line
Count
Source
266
44.9k
    {
267
44.9k
        ::Unserialize(*this, obj);
268
44.9k
        return (*this);
269
44.9k
    }
DataStream& DataStream::operator>><uint256&>(uint256&)
Line
Count
Source
266
18.8k
    {
267
18.8k
        ::Unserialize(*this, obj);
268
18.8k
        return (*this);
269
18.8k
    }
DataStream& DataStream::operator>><BlockTransactionsRequest&>(BlockTransactionsRequest&)
Line
Count
Source
266
222
    {
267
222
        ::Unserialize(*this, obj);
268
222
        return (*this);
269
222
    }
DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> > >(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> >&&)
Line
Count
Source
266
390k
    {
267
390k
        ::Unserialize(*this, obj);
268
390k
        return (*this);
269
390k
    }
DataStream& DataStream::operator>><CBlockHeaderAndShortTxIDs&>(CBlockHeaderAndShortTxIDs&)
Line
Count
Source
266
269
    {
267
269
        ::Unserialize(*this, obj);
268
269
        return (*this);
269
269
    }
DataStream& DataStream::operator>><BlockTransactions&>(BlockTransactions&)
Line
Count
Source
266
357
    {
267
357
        ::Unserialize(*this, obj);
268
357
        return (*this);
269
357
    }
DataStream& DataStream::operator>><CBlockHeader&>(CBlockHeader&)
Line
Count
Source
266
21.6k
    {
267
21.6k
        ::Unserialize(*this, obj);
268
21.6k
        return (*this);
269
21.6k
    }
DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, CBlock> >(ParamsWrapper<TransactionSerParams, CBlock>&&)
Line
Count
Source
266
2.24M
    {
267
2.24M
        ::Unserialize(*this, obj);
268
2.24M
        return (*this);
269
2.24M
    }
DataStream& DataStream::operator>><CBloomFilter&>(CBloomFilter&)
Line
Count
Source
266
511
    {
267
511
        ::Unserialize(*this, obj);
268
511
        return (*this);
269
511
    }
DataStream& DataStream::operator>><std::vector<unsigned char, std::allocator<unsigned char> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&)
Line
Count
Source
266
340
    {
267
340
        ::Unserialize(*this, obj);
268
340
        return (*this);
269
340
    }
DataStream& DataStream::operator>><unsigned char&>(unsigned char&)
Line
Count
Source
266
609
    {
267
609
        ::Unserialize(*this, obj);
268
609
        return (*this);
269
609
    }
Unexecuted instantiation: DataStream& DataStream::operator>><CBlockFileInfo&>(CBlockFileInfo&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::pair<unsigned char, uint256>&>(std::pair<unsigned char, uint256>&)
Unexecuted instantiation: DataStream& DataStream::operator>><CDiskBlockIndex&>(CDiskBlockIndex&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::vector<COutPoint, std::allocator<COutPoint> >&>(std::vector<COutPoint, std::allocator<COutPoint> >&)
Unexecuted instantiation: DataStream& DataStream::operator>><CMerkleBlock&>(CMerkleBlock&)
Unexecuted instantiation: DataStream& DataStream::operator>><Coin&>(Coin&)
Unexecuted instantiation: DataStream& DataStream::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>&&)
Unexecuted instantiation: DataStream& DataStream::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>&&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::span<unsigned char, 18446744073709551615ul> >(std::span<unsigned char, 18446744073709551615ul>&&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::vector<uint256, std::allocator<uint256> >&>(std::vector<uint256, std::allocator<uint256> >&)
Unexecuted instantiation: txdb.cpp:DataStream& DataStream::operator>><(anonymous namespace)::CoinEntry&>((anonymous namespace)::CoinEntry&)
Unexecuted instantiation: DataStream& DataStream::operator>><Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&> >(Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>&&)
blockfilterindex.cpp:DataStream& DataStream::operator>><(anonymous namespace)::DBHeightKey&>((anonymous namespace)::DBHeightKey&)
Line
Count
Source
266
6.51k
    {
267
6.51k
        ::Unserialize(*this, obj);
268
6.51k
        return (*this);
269
6.51k
    }
blockfilterindex.cpp:DataStream& DataStream::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&)
Line
Count
Source
266
9.13k
    {
267
9.13k
        ::Unserialize(*this, obj);
268
9.13k
        return (*this);
269
9.13k
    }
Unexecuted instantiation: blockfilterindex.cpp:DataStream& DataStream::operator>><(anonymous namespace)::DBVal&>((anonymous namespace)::DBVal&)
Unexecuted instantiation: DataStream& DataStream::operator>><FlatFilePos&>(FlatFilePos&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator>><(anonymous namespace)::DBHeightKey&>((anonymous namespace)::DBHeightKey&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&)
Unexecuted instantiation: coinstatsindex.cpp:DataStream& DataStream::operator>><(anonymous namespace)::DBVal&>((anonymous namespace)::DBVal&)
Unexecuted instantiation: DataStream& DataStream::operator>><MuHash3072&>(MuHash3072&)
Unexecuted instantiation: DataStream& DataStream::operator>><CDiskTxPos&>(CDiskTxPos&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
Unexecuted instantiation: DataStream& DataStream::operator>><uint160&>(uint160&)
Unexecuted instantiation: DataStream& DataStream::operator>><CScript&>(CScript&)
Unexecuted instantiation: DataStream& DataStream::operator>><wallet::CKeyMetadata&>(wallet::CKeyMetadata&)
Unexecuted instantiation: DataStream& DataStream::operator>><wallet::WalletDescriptor&>(wallet::WalletDescriptor&)
Unexecuted instantiation: DataStream& DataStream::operator>><transaction_identifier<false>&>(transaction_identifier<false>&)
Unexecuted instantiation: DataStream& DataStream::operator>><wallet::CWalletTx&>(wallet::CWalletTx&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::vector<wallet::CMerkleTx, std::allocator<wallet::CMerkleTx> >&>(std::vector<wallet::CMerkleTx, std::allocator<wallet::CMerkleTx> >&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&>(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&>(std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&)
Unexecuted instantiation: DataStream& DataStream::operator>><CPubKey&>(CPubKey&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::vector<unsigned char, secure_allocator<unsigned char> >&>(std::vector<unsigned char, secure_allocator<unsigned char> >&)
Unexecuted instantiation: DataStream& DataStream::operator>><wallet::CMasterKey&>(wallet::CMasterKey&)
Unexecuted instantiation: DataStream& DataStream::operator>><wallet::CHDChain&>(wallet::CHDChain&)
Unexecuted instantiation: DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, CMutableTransaction> >(ParamsWrapper<TransactionSerParams, CMutableTransaction>&&)
Unexecuted instantiation: DataStream& DataStream::operator>><PartiallySignedTransaction&>(PartiallySignedTransaction&)
Unexecuted instantiation: DataStream& DataStream::operator>><unsigned char (&) [5]>(unsigned char (&) [5])
Unexecuted instantiation: DataStream& DataStream::operator>><unsigned char (&) [4]>(unsigned char (&) [4])
Unexecuted instantiation: DataStream& DataStream::operator>><PSBTInput&>(PSBTInput&)
Unexecuted instantiation: DataStream& DataStream::operator>><std::set<uint256, std::less<uint256>, std::allocator<uint256> >&>(std::set<uint256, std::less<uint256>, std::allocator<uint256> >&)
Unexecuted instantiation: DataStream& DataStream::operator>><PSBTOutput&>(PSBTOutput&)
270
271
    /**
272
     * XOR the contents of this stream with a certain key.
273
     *
274
     * @param[in] key    The key used to XOR the data in this stream.
275
     */
276
    void Xor(const std::vector<unsigned char>& key)
277
6.90M
    {
278
6.90M
        util::Xor(MakeWritableByteSpan(*this), MakeByteSpan(key));
279
6.90M
    }
280
281
    /** Compute total memory usage of this object (own memory + any dynamic memory). */
282
    size_t GetMemoryUsage() const noexcept;
283
};
284
285
template <typename IStream>
286
class BitStreamReader
287
{
288
private:
289
    IStream& m_istream;
290
291
    /// Buffered byte read in from the input stream. A new byte is read into the
292
    /// buffer when m_offset reaches 8.
293
    uint8_t m_buffer{0};
294
295
    /// Number of high order bits in m_buffer already returned by previous
296
    /// Read() calls. The next bit to be returned is at this offset from the
297
    /// most significant bit position.
298
    int m_offset{8};
299
300
public:
301
0
    explicit BitStreamReader(IStream& istream) : m_istream(istream) {}
302
303
    /** Read the specified number of bits from the stream. The data is returned
304
     * in the nbits least significant bits of a 64-bit uint.
305
     */
306
0
    uint64_t Read(int nbits) {
307
0
        if (nbits < 0 || nbits > 64) {
  Branch (307:13): [True: 0, False: 0]
  Branch (307:26): [True: 0, False: 0]
308
0
            throw std::out_of_range("nbits must be between 0 and 64");
309
0
        }
310
311
0
        uint64_t data = 0;
312
0
        while (nbits > 0) {
  Branch (312:16): [True: 0, False: 0]
313
0
            if (m_offset == 8) {
  Branch (313:17): [True: 0, False: 0]
314
0
                m_istream >> m_buffer;
315
0
                m_offset = 0;
316
0
            }
317
318
0
            int bits = std::min(8 - m_offset, nbits);
319
0
            data <<= bits;
320
0
            data |= static_cast<uint8_t>(m_buffer << m_offset) >> (8 - bits);
321
0
            m_offset += bits;
322
0
            nbits -= bits;
323
0
        }
324
0
        return data;
325
0
    }
326
};
327
328
template <typename OStream>
329
class BitStreamWriter
330
{
331
private:
332
    OStream& m_ostream;
333
334
    /// Buffered byte waiting to be written to the output stream. The byte is
335
    /// written buffer when m_offset reaches 8 or Flush() is called.
336
    uint8_t m_buffer{0};
337
338
    /// Number of high order bits in m_buffer already written by previous
339
    /// Write() calls and not yet flushed to the stream. The next bit to be
340
    /// written to is at this offset from the most significant bit position.
341
    int m_offset{0};
342
343
public:
344
2.23M
    explicit BitStreamWriter(OStream& ostream) : m_ostream(ostream) {}
345
346
    ~BitStreamWriter()
347
2.23M
    {
348
2.23M
        Flush();
349
2.23M
    }
350
351
    /** Write the nbits least significant bits of a 64-bit int to the output
352
     * stream. Data is buffered until it completes an octet.
353
     */
354
5.12M
    void Write(uint64_t data, int nbits) {
355
5.12M
        if (nbits < 0 || nbits > 64) {
  Branch (355:13): [True: 0, False: 5.12M]
  Branch (355:26): [True: 0, False: 5.12M]
356
0
            throw std::out_of_range("nbits must be between 0 and 64");
357
0
        }
358
359
14.7M
        while (nbits > 0) {
  Branch (359:16): [True: 9.59M, False: 5.12M]
360
9.59M
            int bits = std::min(8 - m_offset, nbits);
361
9.59M
            m_buffer |= (data << (64 - nbits)) >> (64 - 8 + m_offset);
362
9.59M
            m_offset += bits;
363
9.59M
            nbits -= bits;
364
365
9.59M
            if (m_offset == 8) {
  Branch (365:17): [True: 4.47M, False: 5.12M]
366
4.47M
                Flush();
367
4.47M
            }
368
9.59M
        }
369
5.12M
    }
370
371
    /** Flush any unwritten bits to the output stream, padding with 0's to the
372
     * next byte boundary.
373
     */
374
8.93M
    void Flush() {
375
8.93M
        if (m_offset == 0) {
  Branch (375:13): [True: 2.23M, False: 6.70M]
376
2.23M
            return;
377
2.23M
        }
378
379
6.70M
        m_ostream << m_buffer;
380
6.70M
        m_buffer = 0;
381
6.70M
        m_offset = 0;
382
6.70M
    }
383
};
384
385
/** Non-refcounted RAII wrapper for FILE*
386
 *
387
 * Will automatically close the file when it goes out of scope if not null.
388
 * If you're returning the file pointer, return file.release().
389
 * If you need to close the file early, use file.fclose() instead of fclose(file).
390
 */
391
class AutoFile
392
{
393
protected:
394
    std::FILE* m_file;
395
    std::vector<std::byte> m_xor;
396
    std::optional<int64_t> m_position;
397
398
public:
399
    explicit AutoFile(std::FILE* file, std::vector<std::byte> data_xor={});
400
401
9.08M
    ~AutoFile() { fclose(); }
402
403
    // Disallow copies
404
    AutoFile(const AutoFile&) = delete;
405
    AutoFile& operator=(const AutoFile&) = delete;
406
407
0
    bool feof() const { return std::feof(m_file); }
408
409
    int fclose()
410
9.13M
    {
411
9.13M
        if (auto rel{release()}) return std::fclose(rel);
  Branch (411:18): [True: 9.04M, False: 88.8k]
412
88.8k
        return 0;
413
9.13M
    }
414
415
    /** Get wrapped FILE* with transfer of ownership.
416
     * @note This will invalidate the AutoFile object, and makes it the responsibility of the caller
417
     * of this function to clean up the returned FILE*.
418
     */
419
    std::FILE* release()
420
9.13M
    {
421
9.13M
        std::FILE* ret{m_file};
422
9.13M
        m_file = nullptr;
423
9.13M
        return ret;
424
9.13M
    }
425
426
    /** Return true if the wrapped FILE* is nullptr, false otherwise.
427
     */
428
18.1M
    bool IsNull() const { return m_file == nullptr; }
429
430
    /** Continue with a different XOR key */
431
11.0k
    void SetXor(std::vector<std::byte> data_xor) { m_xor = data_xor; }
432
433
    /** Implementation detail, only used internally. */
434
    std::size_t detail_fread(std::span<std::byte> dst);
435
436
    /** Wrapper around fseek(). Will throw if seeking is not possible. */
437
    void seek(int64_t offset, int origin);
438
439
    /** Find position within the file. Will throw if unknown. */
440
    int64_t tell();
441
442
    /** Wrapper around FileCommit(). */
443
    bool Commit();
444
445
    /** Wrapper around TruncateFile(). */
446
    bool Truncate(unsigned size);
447
448
    //! Write a mutable buffer more efficiently than write(), obfuscating the buffer in-place.
449
    void write_buffer(std::span<std::byte> src);
450
451
    //
452
    // Stream subset
453
    //
454
    void read(std::span<std::byte> dst);
455
    void ignore(size_t nSize);
456
    void write(std::span<const std::byte> src);
457
458
    template <typename T>
459
    AutoFile& operator<<(const T& obj)
460
350M
    {
461
350M
        ::Serialize(*this, obj);
462
350M
        return *this;
463
350M
    }
Unexecuted instantiation: AutoFile& AutoFile::operator<< <std::span<char const, 18446744073709551615ul> >(std::span<char const, 18446744073709551615ul> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <unsigned char>(unsigned char const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <std::span<unsigned char const, 18446744073709551615ul> >(std::span<unsigned char const, 18446744073709551615ul> const&)
AutoFile& AutoFile::operator<< <std::array<std::byte, 8ul> >(std::array<std::byte, 8ul> const&)
Line
Count
Source
460
11.0k
    {
461
11.0k
        ::Serialize(*this, obj);
462
11.0k
        return *this;
463
11.0k
    }
AutoFile& AutoFile::operator<< <unsigned long>(unsigned long const&)
Line
Count
Source
460
343M
    {
461
343M
        ::Serialize(*this, obj);
462
343M
        return *this;
463
343M
    }
AutoFile& AutoFile::operator<< <std::vector<std::byte, std::allocator<std::byte> > >(std::vector<std::byte, std::allocator<std::byte> > const&)
Line
Count
Source
460
11.0k
    {
461
11.0k
        ::Serialize(*this, obj);
462
11.0k
        return *this;
463
11.0k
    }
AutoFile& AutoFile::operator<< <ParamsWrapper<TransactionSerParams, CTransaction const> >(ParamsWrapper<TransactionSerParams, CTransaction const> const&)
Line
Count
Source
460
27.4k
    {
461
27.4k
        ::Serialize(*this, obj);
462
27.4k
        return *this;
463
27.4k
    }
AutoFile& AutoFile::operator<< <long>(long const&)
Line
Count
Source
460
54.8k
    {
461
54.8k
        ::Serialize(*this, obj);
462
54.8k
        return *this;
463
54.8k
    }
AutoFile& AutoFile::operator<< <std::map<uint256, long, std::less<uint256>, std::allocator<std::pair<uint256 const, long> > > >(std::map<uint256, long, std::less<uint256>, std::allocator<std::pair<uint256 const, long> > > const&)
Line
Count
Source
460
11.0k
    {
461
11.0k
        ::Serialize(*this, obj);
462
11.0k
        return *this;
463
11.0k
    }
AutoFile& AutoFile::operator<< <std::span<unsigned char const, 32ul> >(std::span<unsigned char const, 32ul> const&)
Line
Count
Source
460
2.26M
    {
461
2.26M
        ::Serialize(*this, obj);
462
2.26M
        return *this;
463
2.26M
    }
AutoFile& AutoFile::operator<< <std::set<uint256, std::less<uint256>, std::allocator<uint256> > >(std::set<uint256, std::less<uint256>, std::allocator<uint256> > const&)
Line
Count
Source
460
11.0k
    {
461
11.0k
        ::Serialize(*this, obj);
462
11.0k
        return *this;
463
11.0k
    }
fees.cpp:AutoFile& AutoFile::operator<< <Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double const&> >(Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double const&> const&)
Line
Count
Source
460
33.2k
    {
461
33.2k
        ::Serialize(*this, obj);
462
33.2k
        return *this;
463
33.2k
    }
AutoFile& AutoFile::operator<< <unsigned int>(unsigned int const&)
Line
Count
Source
460
66.5k
    {
461
66.5k
        ::Serialize(*this, obj);
462
66.5k
        return *this;
463
66.5k
    }
fees.cpp:AutoFile& AutoFile::operator<< <Wrapper<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter>, std::vector<double, std::allocator<double> > const&> >(Wrapper<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter>, std::vector<double, std::allocator<double> > const&> const&)
Line
Count
Source
460
77.6k
    {
461
77.6k
        ::Serialize(*this, obj);
462
77.6k
        return *this;
463
77.6k
    }
fees.cpp:AutoFile& AutoFile::operator<< <Wrapper<VectorFormatter<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&> >(Wrapper<VectorFormatter<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&> const&)
Line
Count
Source
460
66.5k
    {
461
66.5k
        ::Serialize(*this, obj);
462
66.5k
        return *this;
463
66.5k
    }
AutoFile& AutoFile::operator<< <int>(int const&)
Line
Count
Source
460
22.1k
    {
461
22.1k
        ::Serialize(*this, obj);
462
22.1k
        return *this;
463
22.1k
    }
Unexecuted instantiation: AutoFile& AutoFile::operator<< <transaction_identifier<false> >(transaction_identifier<false> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <Coin>(Coin const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <std::span<unsigned char, 18446744073709551615ul> >(std::span<unsigned char, 18446744073709551615ul> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <node::SnapshotMetadata>(node::SnapshotMetadata const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <std::array<unsigned char, 5ul> >(std::array<unsigned char, 5ul> const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <unsigned short>(unsigned short const&)
Unexecuted instantiation: AutoFile& AutoFile::operator<< <std::array<unsigned char, 4ul> >(std::array<unsigned char, 4ul> const&)
AutoFile& AutoFile::operator<< <uint256>(uint256 const&)
Line
Count
Source
460
2.26M
    {
461
2.26M
        ::Serialize(*this, obj);
462
2.26M
        return *this;
463
2.26M
    }
AutoFile& AutoFile::operator<< <std::vector<unsigned char, std::allocator<unsigned char> > >(std::vector<unsigned char, std::allocator<unsigned char> > const&)
Line
Count
Source
460
2.23M
    {
461
2.23M
        ::Serialize(*this, obj);
462
2.23M
        return *this;
463
2.23M
    }
464
465
    template <typename T>
466
    AutoFile& operator>>(T&& obj)
467
51.3k
    {
468
51.3k
        ::Unserialize(*this, obj);
469
51.3k
        return *this;
470
51.3k
    }
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::array<std::byte, 8ul>&>(std::array<std::byte, 8ul>&)
AutoFile& AutoFile::operator>><std::array<unsigned char, 4ul>&>(std::array<unsigned char, 4ul>&)
Line
Count
Source
467
25.6k
    {
468
25.6k
        ::Unserialize(*this, obj);
469
25.6k
        return *this;
470
25.6k
    }
AutoFile& AutoFile::operator>><unsigned int&>(unsigned int&)
Line
Count
Source
467
25.6k
    {
468
25.6k
        ::Unserialize(*this, obj);
469
25.6k
        return *this;
470
25.6k
    }
Unexecuted instantiation: AutoFile& AutoFile::operator>><unsigned long&>(unsigned long&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::vector<std::byte, std::allocator<std::byte> >&>(std::vector<std::byte, std::allocator<std::byte> >&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> > >(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> >&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><long&>(long&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::map<uint256, long, std::less<uint256>, std::allocator<std::pair<uint256 const, long> > >&>(std::map<uint256, long, std::less<uint256>, std::allocator<std::pair<uint256 const, long> > >&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::set<uint256, std::less<uint256>, std::allocator<uint256> >&>(std::set<uint256, std::less<uint256>, std::allocator<uint256> >&)
Unexecuted instantiation: fees.cpp:AutoFile& AutoFile::operator>><Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double&> >(Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double&>&&)
Unexecuted instantiation: fees.cpp:AutoFile& AutoFile::operator>><Wrapper<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter>, std::vector<double, std::allocator<double> >&> >(Wrapper<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter>, std::vector<double, std::allocator<double> >&>&&)
Unexecuted instantiation: fees.cpp:AutoFile& AutoFile::operator>><Wrapper<VectorFormatter<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&> >(Wrapper<VectorFormatter<VectorFormatter<(anonymous namespace)::EncodedDoubleFormatter> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&>&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><int&>(int&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><node::SnapshotMetadata&>(node::SnapshotMetadata&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::array<unsigned char, 5ul>&>(std::array<unsigned char, 5ul>&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><unsigned short&>(unsigned short&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><uint256&>(uint256&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><transaction_identifier<false>&>(transaction_identifier<false>&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><Coin&>(Coin&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::span<unsigned char, 18446744073709551615ul> >(std::span<unsigned char, 18446744073709551615ul>&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::byte&>(std::byte&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&> >(Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>&&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::vector<unsigned char, std::allocator<unsigned char> >&>(std::vector<unsigned char, std::allocator<unsigned char> >&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><CBlockHeader&>(CBlockHeader&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::MetaPage&>(wallet::MetaPage&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><unsigned char&>(unsigned char&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><std::array<std::byte, 20ul>&>(std::array<std::byte, 20ul>&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><char (&) [368]>(char (&) [368])
Unexecuted instantiation: AutoFile& AutoFile::operator>><char (&) [12]>(char (&) [12])
Unexecuted instantiation: AutoFile& AutoFile::operator>><unsigned char (&) [20]>(unsigned char (&) [20])
Unexecuted instantiation: AutoFile& AutoFile::operator>><unsigned char (&) [16]>(unsigned char (&) [16])
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::PageHeader&>(wallet::PageHeader&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::RecordsPage&>(wallet::RecordsPage&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::RecordHeader&>(wallet::RecordHeader&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::DataRecord&>(wallet::DataRecord&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::OverflowRecord&>(wallet::OverflowRecord&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::InternalPage&>(wallet::InternalPage&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::InternalRecord&>(wallet::InternalRecord&)
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::OverflowPage&>(wallet::OverflowPage&)
471
};
472
473
using DataBuffer = std::vector<std::byte>;
474
475
/** Wrapper around an AutoFile& that implements a ring buffer to
476
 *  deserialize from. It guarantees the ability to rewind a given number of bytes.
477
 *
478
 *  Will automatically close the file when it goes out of scope if not null.
479
 *  If you need to close the file early, use file.fclose() instead of fclose(file).
480
 */
481
class BufferedFile
482
{
483
private:
484
    AutoFile& m_src;
485
    uint64_t nSrcPos{0};  //!< how many bytes have been read from source
486
    uint64_t m_read_pos{0}; //!< how many bytes have been read from this
487
    uint64_t nReadLimit;  //!< up to which position we're allowed to read
488
    uint64_t nRewind;     //!< how many bytes we guarantee to rewind
489
    DataBuffer vchBuf;
490
491
    //! read data from the source to fill the buffer
492
0
    bool Fill() {
493
0
        unsigned int pos = nSrcPos % vchBuf.size();
494
0
        unsigned int readNow = vchBuf.size() - pos;
495
0
        unsigned int nAvail = vchBuf.size() - (nSrcPos - m_read_pos) - nRewind;
496
0
        if (nAvail < readNow)
  Branch (496:13): [True: 0, False: 0]
497
0
            readNow = nAvail;
498
0
        if (readNow == 0)
  Branch (498:13): [True: 0, False: 0]
499
0
            return false;
500
0
        size_t nBytes{m_src.detail_fread(std::span{vchBuf}.subspan(pos, readNow))};
501
0
        if (nBytes == 0) {
  Branch (501:13): [True: 0, False: 0]
502
0
            throw std::ios_base::failure{m_src.feof() ? "BufferedFile::Fill: end of file" : "BufferedFile::Fill: fread failed"};
  Branch (502:42): [True: 0, False: 0]
503
0
        }
504
0
        nSrcPos += nBytes;
505
0
        return true;
506
0
    }
507
508
    //! Advance the stream's read pointer (m_read_pos) by up to 'length' bytes,
509
    //! filling the buffer from the file so that at least one byte is available.
510
    //! Return a pointer to the available buffer data and the number of bytes
511
    //! (which may be less than the requested length) that may be accessed
512
    //! beginning at that pointer.
513
    std::pair<std::byte*, size_t> AdvanceStream(size_t length)
514
0
    {
515
0
        assert(m_read_pos <= nSrcPos);
  Branch (515:9): [True: 0, False: 0]
516
0
        if (m_read_pos + length > nReadLimit) {
  Branch (516:13): [True: 0, False: 0]
517
0
            throw std::ios_base::failure("Attempt to position past buffer limit");
518
0
        }
519
        // If there are no bytes available, read from the file.
520
0
        if (m_read_pos == nSrcPos && length > 0) Fill();
  Branch (520:13): [True: 0, False: 0]
  Branch (520:38): [True: 0, False: 0]
521
522
0
        size_t buffer_offset{static_cast<size_t>(m_read_pos % vchBuf.size())};
523
0
        size_t buffer_available{static_cast<size_t>(vchBuf.size() - buffer_offset)};
524
0
        size_t bytes_until_source_pos{static_cast<size_t>(nSrcPos - m_read_pos)};
525
0
        size_t advance{std::min({length, buffer_available, bytes_until_source_pos})};
526
0
        m_read_pos += advance;
527
0
        return std::make_pair(&vchBuf[buffer_offset], advance);
528
0
    }
529
530
public:
531
    BufferedFile(AutoFile& file LIFETIMEBOUND, uint64_t nBufSize, uint64_t nRewindIn)
532
0
        : m_src{file}, nReadLimit{std::numeric_limits<uint64_t>::max()}, nRewind{nRewindIn}, vchBuf(nBufSize, std::byte{0})
533
0
    {
534
0
        if (nRewindIn >= nBufSize)
  Branch (534:13): [True: 0, False: 0]
535
0
            throw std::ios_base::failure("Rewind limit must be less than buffer size");
536
0
    }
537
538
    //! check whether we're at the end of the source file
539
0
    bool eof() const {
540
0
        return m_read_pos == nSrcPos && m_src.feof();
  Branch (540:16): [True: 0, False: 0]
  Branch (540:41): [True: 0, False: 0]
541
0
    }
542
543
    //! read a number of bytes
544
    void read(std::span<std::byte> dst)
545
0
    {
546
0
        while (dst.size() > 0) {
  Branch (546:16): [True: 0, False: 0]
547
0
            auto [buffer_pointer, length]{AdvanceStream(dst.size())};
548
0
            memcpy(dst.data(), buffer_pointer, length);
549
0
            dst = dst.subspan(length);
550
0
        }
551
0
    }
552
553
    //! Move the read position ahead in the stream to the given position.
554
    //! Use SetPos() to back up in the stream, not SkipTo().
555
    void SkipTo(const uint64_t file_pos)
556
0
    {
557
0
        assert(file_pos >= m_read_pos);
  Branch (557:9): [True: 0, False: 0]
558
0
        while (m_read_pos < file_pos) AdvanceStream(file_pos - m_read_pos);
  Branch (558:16): [True: 0, False: 0]
559
0
    }
560
561
    //! return the current reading position
562
0
    uint64_t GetPos() const {
563
0
        return m_read_pos;
564
0
    }
565
566
    //! rewind to a given reading position
567
0
    bool SetPos(uint64_t nPos) {
568
0
        size_t bufsize = vchBuf.size();
569
0
        if (nPos + bufsize < nSrcPos) {
  Branch (569:13): [True: 0, False: 0]
570
            // rewinding too far, rewind as far as possible
571
0
            m_read_pos = nSrcPos - bufsize;
572
0
            return false;
573
0
        }
574
0
        if (nPos > nSrcPos) {
  Branch (574:13): [True: 0, False: 0]
575
            // can't go this far forward, go as far as possible
576
0
            m_read_pos = nSrcPos;
577
0
            return false;
578
0
        }
579
0
        m_read_pos = nPos;
580
0
        return true;
581
0
    }
582
583
    //! prevent reading beyond a certain position
584
    //! no argument removes the limit
585
0
    bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) {
586
0
        if (nPos < m_read_pos)
  Branch (586:13): [True: 0, False: 0]
587
0
            return false;
588
0
        nReadLimit = nPos;
589
0
        return true;
590
0
    }
591
592
    template<typename T>
593
0
    BufferedFile& operator>>(T&& obj) {
594
0
        ::Unserialize(*this, obj);
595
0
        return (*this);
596
0
    }
Unexecuted instantiation: BufferedFile& BufferedFile::operator>><std::array<unsigned char, 4ul>&>(std::array<unsigned char, 4ul>&)
Unexecuted instantiation: BufferedFile& BufferedFile::operator>><unsigned int&>(unsigned int&)
Unexecuted instantiation: BufferedFile& BufferedFile::operator>><CBlockHeader&>(CBlockHeader&)
Unexecuted instantiation: BufferedFile& BufferedFile::operator>><ParamsWrapper<TransactionSerParams, CBlock> >(ParamsWrapper<TransactionSerParams, CBlock>&&)
597
598
    //! search for a given byte in the stream, and remain positioned on it
599
    void FindByte(std::byte byte)
600
0
    {
601
        // For best performance, avoid mod operation within the loop.
602
0
        size_t buf_offset{size_t(m_read_pos % uint64_t(vchBuf.size()))};
603
0
        while (true) {
  Branch (603:16): [Folded - Ignored]
604
0
            if (m_read_pos == nSrcPos) {
  Branch (604:17): [True: 0, False: 0]
605
                // No more bytes available; read from the file into the buffer,
606
                // setting nSrcPos to one beyond the end of the new data.
607
                // Throws exception if end-of-file reached.
608
0
                Fill();
609
0
            }
610
0
            const size_t len{std::min<size_t>(vchBuf.size() - buf_offset, nSrcPos - m_read_pos)};
611
0
            const auto it_start{vchBuf.begin() + buf_offset};
612
0
            const auto it_find{std::find(it_start, it_start + len, byte)};
613
0
            const size_t inc{size_t(std::distance(it_start, it_find))};
614
0
            m_read_pos += inc;
615
0
            if (inc < len) break;
  Branch (615:17): [True: 0, False: 0]
616
0
            buf_offset += inc;
617
0
            if (buf_offset >= vchBuf.size()) buf_offset = 0;
  Branch (617:17): [True: 0, False: 0]
618
0
        }
619
0
    }
620
};
621
622
/**
623
 * Wrapper that buffers reads from an underlying stream.
624
 * Requires underlying stream to support read() and detail_fread() calls
625
 * to support fixed-size and variable-sized reads, respectively.
626
 */
627
template <typename S>
628
class BufferedReader
629
{
630
    S& m_src;
631
    DataBuffer m_buf;
632
    size_t m_buf_pos;
633
634
public:
635
    //! Requires stream ownership to prevent leaving the stream at an unexpected position after buffered reads.
636
    explicit BufferedReader(S&& stream LIFETIMEBOUND, size_t size = 1 << 16)
637
        requires std::is_rvalue_reference_v<S&&>
638
2.22M
        : m_src{stream}, m_buf(size), m_buf_pos{size} {}
639
640
    void read(std::span<std::byte> dst)
641
4.68M
    {
642
4.68M
        if (const auto available{std::min(dst.size(), m_buf.size() - m_buf_pos)}) {
  Branch (642:24): [True: 2.45M, False: 2.22M]
643
2.45M
            std::copy_n(m_buf.begin() + m_buf_pos, available, dst.begin());
644
2.45M
            m_buf_pos += available;
645
2.45M
            dst = dst.subspan(available);
646
2.45M
        }
647
4.68M
        if (dst.size()) {
  Branch (647:13): [True: 2.22M, False: 2.45M]
648
2.22M
            assert(m_buf_pos == m_buf.size());
  Branch (648:13): [True: 2.22M, False: 0]
649
2.22M
            m_src.read(dst);
650
651
2.22M
            m_buf_pos = 0;
652
2.22M
            m_buf.resize(m_src.detail_fread(m_buf));
653
2.22M
        }
654
4.68M
    }
655
656
    template <typename T>
657
    BufferedReader& operator>>(T&& obj)
658
2.22M
    {
659
2.22M
        Unserialize(*this, obj);
660
2.22M
        return *this;
661
2.22M
    }
662
};
663
664
/**
665
 * Wrapper that buffers writes to an underlying stream.
666
 * Requires underlying stream to support write_buffer() method
667
 * for efficient buffer flushing and obfuscation.
668
 */
669
template <typename S>
670
class BufferedWriter
671
{
672
    S& m_dst;
673
    DataBuffer m_buf;
674
    size_t m_buf_pos{0};
675
676
public:
677
4.46M
    explicit BufferedWriter(S& stream LIFETIMEBOUND, size_t size = 1 << 16) : m_dst{stream}, m_buf(size) {}
678
679
4.46M
    ~BufferedWriter() { flush(); }
680
681
    void flush()
682
6.69M
    {
683
6.69M
        if (m_buf_pos) m_dst.write_buffer(std::span{m_buf}.first(m_buf_pos));
  Branch (683:13): [True: 4.47M, False: 2.22M]
684
6.69M
        m_buf_pos = 0;
685
6.69M
    }
686
687
    void write(std::span<const std::byte> src)
688
75.4M
    {
689
150M
        while (const auto available{std::min(src.size(), m_buf.size() - m_buf_pos)}) {
  Branch (689:27): [True: 75.4M, False: 75.4M]
690
75.4M
            std::copy_n(src.begin(), available, m_buf.begin() + m_buf_pos);
691
75.4M
            m_buf_pos += available;
692
75.4M
            if (m_buf_pos == m_buf.size()) flush();
  Branch (692:17): [True: 6.91k, False: 75.4M]
693
75.4M
            src = src.subspan(available);
694
75.4M
        }
695
75.4M
    }
696
697
    template <typename T>
698
    BufferedWriter& operator<<(const T& obj)
699
17.8M
    {
700
17.8M
        Serialize(*this, obj);
701
17.8M
        return *this;
702
17.8M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <std::array<unsigned char, 4ul> >(std::array<unsigned char, 4ul> const&)
Line
Count
Source
699
4.46M
    {
700
4.46M
        Serialize(*this, obj);
701
4.46M
        return *this;
702
4.46M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <unsigned int>(unsigned int const&)
Line
Count
Source
699
4.46M
    {
700
4.46M
        Serialize(*this, obj);
701
4.46M
        return *this;
702
4.46M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <CBlockUndo>(CBlockUndo const&)
Line
Count
Source
699
2.22M
    {
700
2.22M
        Serialize(*this, obj);
701
2.22M
        return *this;
702
2.22M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&)
Line
Count
Source
699
12.0k
    {
700
12.0k
        Serialize(*this, obj);
701
12.0k
        return *this;
702
12.0k
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <std::span<unsigned char, 18446744073709551615ul> >(std::span<unsigned char, 18446744073709551615ul> const&)
Line
Count
Source
699
166
    {
700
166
        Serialize(*this, obj);
701
166
        return *this;
702
166
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> >(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&)
Line
Count
Source
699
11.8k
    {
700
11.8k
        Serialize(*this, obj);
701
11.8k
        return *this;
702
11.8k
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <std::span<unsigned char const, 18446744073709551615ul> >(std::span<unsigned char const, 18446744073709551615ul> const&)
Line
Count
Source
699
11.8k
    {
700
11.8k
        Serialize(*this, obj);
701
11.8k
        return *this;
702
11.8k
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <uint256>(uint256 const&)
Line
Count
Source
699
2.22M
    {
700
2.22M
        Serialize(*this, obj);
701
2.22M
        return *this;
702
2.22M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <std::span<unsigned char const, 32ul> >(std::span<unsigned char const, 32ul> const&)
Line
Count
Source
699
2.22M
    {
700
2.22M
        Serialize(*this, obj);
701
2.22M
        return *this;
702
2.22M
    }
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<< <ParamsWrapper<TransactionSerParams, CBlock const> >(ParamsWrapper<TransactionSerParams, CBlock const> const&)
Line
Count
Source
699
2.24M
    {
700
2.24M
        Serialize(*this, obj);
701
2.24M
        return *this;
702
2.24M
    }
703
};
704
705
#endif // BITCOIN_STREAMS_H