/Users/eugenesiegel/btc/bitcoin/src/streams.h
| Line | Count | Source (jump to first uncovered line) | 
| 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 <logging.h> | 
| 10 |  | #include <serialize.h> | 
| 11 |  | #include <span.h> | 
| 12 |  | #include <support/allocators/zeroafterfree.h> | 
| 13 |  | #include <util/check.h> | 
| 14 |  | #include <util/obfuscation.h> | 
| 15 |  | #include <util/overflow.h> | 
| 16 |  | #include <util/syserror.h> | 
| 17 |  |  | 
| 18 |  | #include <algorithm> | 
| 19 |  | #include <cassert> | 
| 20 |  | #include <cstddef> | 
| 21 |  | #include <cstdint> | 
| 22 |  | #include <cstdio> | 
| 23 |  | #include <cstring> | 
| 24 |  | #include <ios> | 
| 25 |  | #include <limits> | 
| 26 |  | #include <optional> | 
| 27 |  | #include <string> | 
| 28 |  | #include <vector> | 
| 29 |  |  | 
| 30 |  | /* Minimal stream for overwriting and/or appending to an existing byte vector | 
| 31 |  |  * | 
| 32 |  |  * The referenced vector will grow as necessary | 
| 33 |  |  */ | 
| 34 |  | class VectorWriter | 
| 35 |  | { | 
| 36 |  | public: | 
| 37 |  | /* | 
| 38 |  |  * @param[in]  vchDataIn  Referenced byte vector to overwrite/append | 
| 39 |  |  * @param[in]  nPosIn Starting position. Vector index where writes should start. The vector will initially | 
| 40 |  |  *                    grow as necessary to max(nPosIn, vec.size()). So to append, use vec.size(). | 
| 41 |  | */ | 
| 42 | 16.6M |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn) : vchData{vchDataIn}, nPos{nPosIn} | 
| 43 | 16.6M |     { | 
| 44 | 16.6M |         if(nPos > vchData.size()) | 
| 45 | 0 |             vchData.resize(nPos); | 
| 46 | 16.6M |     } | 
| 47 |  | /* | 
| 48 |  |  * (other params same as above) | 
| 49 |  |  * @param[in]  args  A list of items to serialize starting at nPosIn. | 
| 50 |  | */ | 
| 51 |  |     template <typename... Args> | 
| 52 | 15.8M |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 
| 53 | 15.8M |     { | 
| 54 | 15.8M |         ::SerializeMany(*this, std::forward<Args>(args)...); | 
| 55 | 15.8M |     } _ZN12VectorWriterC1IJR25CBlockHeaderAndShortTxIDsEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 1.59M |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 1.59M |     { |  | 54 | 1.59M |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 1.59M |     } | 
_ZN12VectorWriterC1IJR17BlockTransactionsEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 276k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 276k |     { |  | 54 | 276k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 276k |     } | 
_ZN12VectorWriterC1IJ13ParamsWrapperI20TransactionSerParamsNSt3__16vectorI6CBlockNS3_9allocatorIS5_EEEEEEEERNS4_IhNS6_IhEEEEmDpOT_| Line | Count | Source |  | 52 | 916k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 916k |     { |  | 54 | 916k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 916k |     } | 
_ZN12VectorWriterC1IJRbRKyEEERNSt3__16vectorIhNS4_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 74.0k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 74.0k |     { |  | 54 | 74.0k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 74.0k |     } | 
_ZN12VectorWriterC1IJ13ParamsWrapperI20TransactionSerParamsK12CTransactionEEEERNSt3__16vectorIhNS6_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 3.68M |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 3.68M |     { |  | 54 | 3.68M |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 3.68M |     } | 
Unexecuted instantiation: _ZN12VectorWriterC1IJ13ParamsWrapperI20TransactionSerParams25CBlockHeaderAndShortTxIDsEEEERNSt3__16vectorIhNS5_9allocatorIhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJ13ParamsWrapperI20TransactionSerParams6CBlockEEEERNSt3__16vectorIhNS5_9allocatorIhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJNSt3__14spanISt4byteLm18446744073709551615EEEEEERNS1_6vectorIhNS1_9allocatorIhEEEEmDpOT__ZN12VectorWriterC1IJRi7WrapperI19CustomUintFormatterILi8ELb0EER12ServiceFlagsExx13ParamsWrapperIN8CNetAddr9SerParamsE8CServiceExSC_yNSt3__112basic_stringIcNSD_11char_traitsIcEENSD_9allocatorIcEEEEiRbEEERNSD_6vectorIhNSH_IhEEEEmDpOT_| Line | Count | Source |  | 52 | 192k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 192k |     { |  | 54 | 192k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 192k |     } | 
_ZN12VectorWriterC1IJR14CMessageHeaderEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 8.05M |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 8.05M |     { |  | 54 | 8.05M |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 8.05M |     } | 
_ZN12VectorWriterC1IJbRKyEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 108k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 108k |     { |  | 54 | 108k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 108k |     } | 
_ZN12VectorWriterC1IJRK25CBlockHeaderAndShortTxIDsEEERNSt3__16vectorIhNS4_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 2.64k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 2.64k |     { |  | 54 | 2.64k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 2.64k |     } | 
_ZN12VectorWriterC1IJRNSt3__16vectorI4CInvNS1_9allocatorIS3_EEEEEEERNS2_IhNS4_IhEEEEmDpOT_| Line | Count | Source |  | 52 | 526k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 526k |     { |  | 54 | 526k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 526k |     } | 
_ZN12VectorWriterC1IJRKiRyRKxS3_13ParamsWrapperIN8CNetAddr9SerParamsE8CServiceES3_SA_S3_RNSt3__112basic_stringIcNSB_11char_traitsIcEENSB_9allocatorIcEEEES2_RKbEEERNSB_6vectorIhNSF_IhEEEEmDpOT_| Line | Count | Source |  | 52 | 192k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 192k |     { |  | 54 | 192k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 192k |     } | 
Unexecuted instantiation: _ZN12VectorWriterC1IJRKjRKyEEERNSt3__16vectorIhNS5_9allocatorIhEEEEmDpOT__ZN12VectorWriterC1IJRKNSt3__15arrayISt4byteLm168EEEEEERNS1_6vectorIhNS1_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 5.66k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 5.66k |     { |  | 54 | 5.66k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 5.66k |     } | 
_ZN12VectorWriterC1IJRK13CBlockLocator7uint256EEERNSt3__16vectorIhNS5_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 71.6k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 71.6k |     { |  | 54 | 71.6k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 71.6k |     } | 
Unexecuted instantiation: _ZN12VectorWriterC1IJ13ParamsWrapperI20TransactionSerParamsK6CBlockEEEERNSt3__16vectorIhNS6_9allocatorIhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJR12CMerkleBlockEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJNSt3__16vectorI12CBlockHeaderNS1_9allocatorIS3_EEEEEEERNS2_IhNS4_IhEEEEmDpOT__ZN12VectorWriterC1IJR24BlockTransactionsRequestEEERNSt3__16vectorIhNS3_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 16.5k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 16.5k |     { |  | 54 | 16.5k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 16.5k |     } | 
_ZN12VectorWriterC1IJRyEEERNSt3__16vectorIhNS2_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 106k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 106k |     { |  | 54 | 106k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 106k |     } | 
Unexecuted instantiation: _ZN12VectorWriterC1IJRK11BlockFilterEEERNSt3__16vectorIhNS4_9allocatorIhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJRh7uint256RS2_RNSt3__16vectorIS2_NS4_9allocatorIS2_EEEEEEERNS5_IhNS6_IhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJRh7uint256RNSt3__16vectorIS2_NS3_9allocatorIS2_EEEEEEERNS4_IhNS5_IhEEEEmDpOT_Unexecuted instantiation: _ZN12VectorWriterC1IJ13ParamsWrapperIN8CAddress9SerParamsENSt3__16vectorIS2_NS4_9allocatorIS2_EEEEEEEERNS5_IhNS6_IhEEEEmDpOT__ZN12VectorWriterC1IJRxEEERNSt3__16vectorIhNS2_9allocatorIhEEEEmDpOT_| Line | Count | Source |  | 52 | 69.6k |     VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |  | 53 | 69.6k |     { |  | 54 | 69.6k |         ::SerializeMany(*this, std::forward<Args>(args)...); |  | 55 | 69.6k |     } | 
 | 
| 56 |  |     void write(std::span<const std::byte> src) | 
| 57 | 169M |     { | 
| 58 | 169M |         assert(nPos <= vchData.size()); | 
| 59 | 169M |         size_t nOverwrite = std::min(src.size(), vchData.size() - nPos); | 
| 60 | 169M |         if (nOverwrite) { | 
| 61 | 0 |             memcpy(vchData.data() + nPos, src.data(), nOverwrite); | 
| 62 | 0 |         } | 
| 63 | 169M |         if (nOverwrite < src.size()) { | 
| 64 | 169M |             vchData.insert(vchData.end(), UCharCast(src.data()) + nOverwrite, UCharCast(src.data() + src.size())); | 
| 65 | 169M |         } | 
| 66 | 169M |         nPos += src.size(); | 
| 67 | 169M |     } | 
| 68 |  |     template <typename T> | 
| 69 |  |     VectorWriter& operator<<(const T& obj) | 
| 70 | 5.45M |     { | 
| 71 | 5.45M |         ::Serialize(*this, obj); | 
| 72 | 5.45M |         return (*this); | 
| 73 | 5.45M |     } Unexecuted instantiation: cluster_linearize.cpp:_ZN12VectorWriterlsI7WrapperIN12_GLOBAL__N_117DepGraphFormatterERKN17cluster_linearize8DepGraphIN13bitset_detail9IntBitSetIjEEEEEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsI7WrapperI15VarIntFormatterIL10VarIntMode1EERKiEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsIhEERS_RKT__ZN12VectorWriterlsINSt3__14spanIKhLm32EEEEERS_RKT_| Line | Count | Source |  | 70 | 5.45M |     { |  | 71 | 5.45M |         ::Serialize(*this, obj); |  | 72 | 5.45M |         return (*this); |  | 73 | 5.45M |     } | 
Unexecuted instantiation: _ZN12VectorWriterlsINSt3__13setI7uint256NS1_4lessIS3_EENS1_9allocatorIS3_EEEEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsIA4_hEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsIjEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsINSt3__14spanIKhLm18446744073709551615EEEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsINSt3__16vectorIhNS1_9allocatorIhEEEEEERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsI7uint256EERS_RKT_Unexecuted instantiation: _ZN12VectorWriterlsIiEERS_RKT_ | 
| 74 |  |  | 
| 75 |  | private: | 
| 76 |  |     std::vector<unsigned char>& vchData; | 
| 77 |  |     size_t nPos; | 
| 78 |  | }; | 
| 79 |  |  | 
| 80 |  | /** Minimal stream for reading from an existing byte array by std::span. | 
| 81 |  |  */ | 
| 82 |  | class SpanReader | 
| 83 |  | { | 
| 84 |  | private: | 
| 85 |  |     std::span<const std::byte> m_data; | 
| 86 |  |  | 
| 87 |  | public: | 
| 88 |  |     /** | 
| 89 |  |      * @param[in]  data Referenced byte vector to overwrite/append | 
| 90 |  |      */ | 
| 91 | 0 |     explicit SpanReader(std::span<const unsigned char> data) : m_data{std::as_bytes(data)} {} | 
| 92 | 308k |     explicit SpanReader(std::span<const std::byte> data) : m_data{data} {} | 
| 93 |  |  | 
| 94 |  |     template<typename T> | 
| 95 |  |     SpanReader& operator>>(T&& obj) | 
| 96 | 308k |     { | 
| 97 | 308k |         ::Unserialize(*this, obj); | 
| 98 | 308k |         return (*this); | 
| 99 | 308k |     } Unexecuted instantiation: cluster_linearize.cpp:_ZN10SpanReaderrsI7WrapperIN12_GLOBAL__N_117DepGraphFormatterERN17cluster_linearize8DepGraphIN13bitset_detail9IntBitSetIjEEEEEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsI7WrapperI15VarIntFormatterIL10VarIntMode1EERiEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIRyEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIRhEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIRNSt3__16vectorIhNS1_9allocatorIhEEEEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIR11XOnlyPubKeyEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIR7uint256EERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsINSt3__14spanISt4byteLm33EEEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsI13ParamsWrapperI20TransactionSerParams19CMutableTransactionEEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIR6CTxOutEERS_OT__ZN10SpanReaderrsI13ParamsWrapperI20TransactionSerParams6CBlockEEERS_OT_| Line | Count | Source |  | 96 | 308k |     { |  | 97 | 308k |         ::Unserialize(*this, obj); |  | 98 | 308k |         return (*this); |  | 99 | 308k |     } | 
Unexecuted instantiation: _ZN10SpanReaderrsIR7CScriptEERS_OT_Unexecuted instantiation: _ZN10SpanReaderrsIRNSt3__16vectorINS2_IhNS1_9allocatorIhEEEENS3_IS5_EEEEEERS_OT_ | 
| 100 |  |  | 
| 101 | 0 |     size_t size() const { return m_data.size(); } | 
| 102 | 0 |     bool empty() const { return m_data.empty(); } | 
| 103 |  |  | 
| 104 |  |     void read(std::span<std::byte> dst) | 
| 105 | 8.37M |     { | 
| 106 | 8.37M |         if (dst.size() == 0) { | 
| 107 | 0 |             return; | 
| 108 | 0 |         } | 
| 109 |  |  | 
| 110 |  |         // Read from the beginning of the buffer | 
| 111 | 8.37M |         if (dst.size() > m_data.size()) { | 
| 112 | 0 |             throw std::ios_base::failure("SpanReader::read(): end of data"); | 
| 113 | 0 |         } | 
| 114 | 8.37M |         memcpy(dst.data(), m_data.data(), dst.size()); | 
| 115 | 8.37M |         m_data = m_data.subspan(dst.size()); | 
| 116 | 8.37M |     } | 
| 117 |  |  | 
| 118 |  |     void ignore(size_t n) | 
| 119 | 0 |     { | 
| 120 | 0 |         m_data = m_data.subspan(n); | 
| 121 | 0 |     } | 
| 122 |  | }; | 
| 123 |  |  | 
| 124 |  | /** Double ended buffer combining vector and stream-like interfaces. | 
| 125 |  |  * | 
| 126 |  |  * >> and << read and write unformatted data using the above serialization templates. | 
| 127 |  |  * Fills with data in linear time; some stringstream implementations take N^2 time. | 
| 128 |  |  */ | 
| 129 |  | class DataStream | 
| 130 |  | { | 
| 131 |  | protected: | 
| 132 |  |     using vector_type = SerializeData; | 
| 133 |  |     vector_type vch; | 
| 134 |  |     vector_type::size_type m_read_pos{0}; | 
| 135 |  |  | 
| 136 |  | public: | 
| 137 |  |     typedef vector_type::allocator_type   allocator_type; | 
| 138 |  |     typedef vector_type::size_type        size_type; | 
| 139 |  |     typedef vector_type::difference_type  difference_type; | 
| 140 |  |     typedef vector_type::reference        reference; | 
| 141 |  |     typedef vector_type::const_reference  const_reference; | 
| 142 |  |     typedef vector_type::value_type       value_type; | 
| 143 |  |     typedef vector_type::iterator         iterator; | 
| 144 |  |     typedef vector_type::const_iterator   const_iterator; | 
| 145 |  |     typedef vector_type::reverse_iterator reverse_iterator; | 
| 146 |  |  | 
| 147 | 5.89M |     explicit DataStream() = default; | 
| 148 | 0 |     explicit DataStream(std::span<const uint8_t> sp) : DataStream{std::as_bytes(sp)} {} | 
| 149 | 22.2M |     explicit DataStream(std::span<const value_type> sp) : vch(sp.data(), sp.data() + sp.size()) {} | 
| 150 |  |  | 
| 151 |  |     std::string str() const | 
| 152 | 0 |     { | 
| 153 | 0 |         return std::string{UCharCast(data()), UCharCast(data() + size())}; | 
| 154 | 0 |     } | 
| 155 |  |  | 
| 156 |  |  | 
| 157 |  |     // | 
| 158 |  |     // Vector subset | 
| 159 |  |     // | 
| 160 | 0 |     const_iterator begin() const                     { return vch.begin() + m_read_pos; } | 
| 161 | 5.93M |     iterator begin()                                 { return vch.begin() + m_read_pos; } | 
| 162 | 0 |     const_iterator end() const                       { return vch.end(); } | 
| 163 | 2.96M |     iterator end()                                   { return vch.end(); } | 
| 164 | 20.9M |     size_type size() const                           { return vch.size() - m_read_pos; } | 
| 165 | 763k |     bool empty() const                               { return vch.size() == m_read_pos; } | 
| 166 | 13.7M |     void resize(size_type n, value_type c = value_type{}) { vch.resize(n + m_read_pos, c); } | 
| 167 | 2.23M |     void reserve(size_type n)                        { vch.reserve(n + m_read_pos); } | 
| 168 | 0 |     const_reference operator[](size_type pos) const  { return vch[pos + m_read_pos]; } | 
| 169 | 13.5M |     reference operator[](size_type pos)              { return vch[pos + m_read_pos]; } | 
| 170 | 14.1M |     void clear()                                     { vch.clear(); m_read_pos = 0; } | 
| 171 | 14.1M |     value_type* data()                               { return vch.data() + m_read_pos; } | 
| 172 | 0 |     const value_type* data() const                   { return vch.data() + m_read_pos; } | 
| 173 |  |  | 
| 174 |  |     inline void Compact() | 
| 175 | 0 |     { | 
| 176 | 0 |         vch.erase(vch.begin(), vch.begin() + m_read_pos); | 
| 177 | 0 |         m_read_pos = 0; | 
| 178 | 0 |     } | 
| 179 |  |  | 
| 180 |  |     bool Rewind(std::optional<size_type> n = std::nullopt) | 
| 181 | 0 |     { | 
| 182 | 0 |         // Total rewind if no size is passed | 
| 183 | 0 |         if (!n) { | 
| 184 | 0 |             m_read_pos = 0; | 
| 185 | 0 |             return true; | 
| 186 | 0 |         } | 
| 187 | 0 |         // Rewind by n characters if the buffer hasn't been compacted yet | 
| 188 | 0 |         if (*n > m_read_pos) | 
| 189 | 0 |             return false; | 
| 190 | 0 |         m_read_pos -= *n; | 
| 191 | 0 |         return true; | 
| 192 | 0 |     } | 
| 193 |  |  | 
| 194 |  |  | 
| 195 |  |     // | 
| 196 |  |     // Stream subset | 
| 197 |  |     // | 
| 198 | 0 |     bool eof() const             { return size() == 0; } | 
| 199 | 0 |     int in_avail() const         { return size(); } | 
| 200 |  |  | 
| 201 |  |     void read(std::span<value_type> dst) | 
| 202 | 369M |     { | 
| 203 | 369M |         if (dst.size() == 0) return0; | 
| 204 |  |  | 
| 205 |  |         // Read from the beginning of the buffer | 
| 206 | 369M |         auto next_read_pos{CheckedAdd(m_read_pos, dst.size())}; | 
| 207 | 369M |         if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) { | 
| 208 | 51.2k |             throw std::ios_base::failure("DataStream::read(): end of data"); | 
| 209 | 51.2k |         } | 
| 210 | 369M |         memcpy(dst.data(), &vch[m_read_pos], dst.size()); | 
| 211 | 369M |         if (next_read_pos.value() == vch.size()) { | 
| 212 | 35.5M |             m_read_pos = 0; | 
| 213 | 35.5M |             vch.clear(); | 
| 214 | 35.5M |             return; | 
| 215 | 35.5M |         } | 
| 216 | 334M |         m_read_pos = next_read_pos.value(); | 
| 217 | 334M |     } | 
| 218 |  |  | 
| 219 |  |     void ignore(size_t num_ignore) | 
| 220 | 382k |     { | 
| 221 |  |         // Ignore from the beginning of the buffer | 
| 222 | 382k |         auto next_read_pos{CheckedAdd(m_read_pos, num_ignore)}; | 
| 223 | 382k |         if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) { | 
| 224 | 0 |             throw std::ios_base::failure("DataStream::ignore(): end of data"); | 
| 225 | 0 |         } | 
| 226 | 382k |         if (next_read_pos.value() == vch.size()) { | 
| 227 | 0 |             m_read_pos = 0; | 
| 228 | 0 |             vch.clear(); | 
| 229 | 0 |             return; | 
| 230 | 0 |         } | 
| 231 | 382k |         m_read_pos = next_read_pos.value(); | 
| 232 | 382k |     } | 
| 233 |  |  | 
| 234 |  |     void write(std::span<const value_type> src) | 
| 235 | 27.9M |     { | 
| 236 |  |         // Write to the end of the buffer | 
| 237 | 27.9M |         vch.insert(vch.end(), src.begin(), src.end()); | 
| 238 | 27.9M |     } | 
| 239 |  |  | 
| 240 |  |     template<typename T> | 
| 241 |  |     DataStream& operator<<(const T& obj) | 
| 242 | 16.5M |     { | 
| 243 | 16.5M |         ::Serialize(*this, obj); | 
| 244 | 16.5M |         return (*this); | 
| 245 | 16.5M |     } Unexecuted instantiation: _ZN10DataStreamlsI7AddrManEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI20AddrManDeterministicEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI11BlockFilterEERS_RKT__ZN10DataStreamlsIhEERS_RKT_| Line | Count | Source |  | 242 | 666k |     { |  | 243 | 666k |         ::Serialize(*this, obj); |  | 244 | 666k |         return (*this); |  | 245 | 666k |     } | 
_ZN10DataStreamlsI7uint256EERS_RKT_| Line | Count | Source |  | 242 | 4.58k |     { |  | 243 | 4.58k |         ::Serialize(*this, obj); |  | 244 | 4.58k |         return (*this); |  | 245 | 4.58k |     } | 
_ZN10DataStreamlsINSt3__14spanIKhLm32EEEEERS_RKT_| Line | Count | Source |  | 242 | 7.62M |     { |  | 243 | 7.62M |         ::Serialize(*this, obj); |  | 244 | 7.62M |         return (*this); |  | 245 | 7.62M |     } | 
_ZN10DataStreamlsINSt3__16vectorIhNS1_9allocatorIhEEEEEERS_RKT_| Line | Count | Source |  | 242 | 382k |     { |  | 243 | 382k |         ::Serialize(*this, obj); |  | 244 | 382k |         return (*this); |  | 245 | 382k |     } | 
_ZN10DataStreamlsI14CBlockFileInfoEERS_RKT_| Line | Count | Source |  | 242 | 1.89k |     { |  | 243 | 1.89k |         ::Serialize(*this, obj); |  | 244 | 1.89k |         return (*this); |  | 245 | 1.89k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI25CBlockHeaderAndShortTxIDsEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI8CFeeRateEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI12CMerkleBlockEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI9COutPointEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI18CPartialMerkleTreeEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI7CPubKeyEERS_RKT__ZN10DataStreamlsINSt3__14spanIKhLm18446744073709551615EEEEERS_RKT_| Line | Count | Source |  | 242 | 10.1k |     { |  | 243 | 10.1k |         ::Serialize(*this, obj); |  | 244 | 10.1k |         return (*this); |  | 245 | 10.1k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI7CScriptEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI5CTxInEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI11FlatFilePosEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13KeyOriginInfoEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI26PartiallySignedTransactionEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIA5_hEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIA4_hEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIjEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI9PSBTInputEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI10PSBTOutputEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI20PrefilledTransactionEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperI20TransactionSerParams6CBlockEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13CBlockLocatorEERS_RKT__ZN10DataStreamlsI12CBlockHeaderEERS_RKT_| Line | Count | Source |  | 242 | 2.96M |     { |  | 243 | 2.96M |         ::Serialize(*this, obj); |  | 244 | 2.96M |         return (*this); |  | 245 | 2.96M |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI7CTxUndoEERS_RKT__ZN10DataStreamlsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_RKT_| Line | Count | Source |  | 242 | 10.1k |     { |  | 243 | 10.1k |         ::Serialize(*this, obj); |  | 244 | 10.1k |         return (*this); |  | 245 | 10.1k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsINSt3__14spanIhLm18446744073709551615EEEEERS_RKT__ZN10DataStreamlsI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS_RKT_| Line | Count | Source |  | 242 | 10.1k |     { |  | 243 | 10.1k |         ::Serialize(*this, obj); |  | 244 | 10.1k |         return (*this); |  | 245 | 10.1k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI10CBlockUndoEERS_RKT__ZN10DataStreamlsI4CoinEERS_RKT_| Line | Count | Source |  | 242 | 10.1k |     { |  | 243 | 10.1k |         ::Serialize(*this, obj); |  | 244 | 10.1k |         return (*this); |  | 245 | 10.1k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperIN8CNetAddr9SerParamsEKS2_EEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperIN8CNetAddr9SerParamsEK8CServiceEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI14CMessageHeaderEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperIN8CAddress9SerParamsEKS2_EEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI4CInvEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI12CBloomFilterEERS_RKT__ZN10DataStreamlsI15CDiskBlockIndexEERS_RKT_| Line | Count | Source |  | 242 | 10.4k |     { |  | 243 | 10.4k |         ::Serialize(*this, obj); |  | 244 | 10.4k |         return (*this); |  | 245 | 10.4k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI7WrapperI16TxOutCompressionR6CTxOutEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI17BlockTransactionsEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI24BlockTransactionsRequestEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIN4node16SnapshotMetadataEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__15arrayIhLm5EEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsItEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__15arrayIhLm4EEEEERS_RKT__ZN10DataStreamlsIyEERS_RKT_| Line | Count | Source |  | 242 | 2.96M |     { |  | 243 | 2.96M |         ::Serialize(*this, obj); |  | 244 | 2.96M |         return (*this); |  | 245 | 2.96M |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI7uint160EERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14spanIKhLm20EEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIxEERS_RKT__ZN10DataStreamlsIiEERS_RKT_| Line | Count | Source |  | 242 | 4.58k |     { |  | 243 | 4.58k |         ::Serialize(*this, obj); |  | 244 | 4.58k |         return (*this); |  | 245 | 4.58k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsIsEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIaEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIbEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__16vectorIiNS1_9allocatorIiEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI9prevectorILj8EijiEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperI20TransactionSerParams19CMutableTransactionEEERS_RKT__ZN10DataStreamlsINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEERS_RKT_| Line | Count | Source |  | 242 | 102k |     { |  | 243 | 102k |         ::Serialize(*this, obj); |  | 244 | 102k |         return (*this); |  | 245 | 102k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI7WrapperI22LimitedStringFormatterILm10EERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperI20TransactionSerParamsK12CTransactionEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14spanIKSt4byteLm18446744073709551615EEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES8_EEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE22transaction_identifierILb0EEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIN6wallet9CWalletTxEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperI20TransactionSerParamsKNSt3__110shared_ptrIK12CTransactionEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__13mapINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES8_NS1_4lessIS8_EENS6_INS1_4pairIKS8_S8_EEEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__16vectorINS1_4pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_EENS7_ISA_EEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE7uint256EEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE7CPubKeyEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIN6wallet12CKeyMetadataEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_6vectorIh16secure_allocatorIhEEE7uint256EEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_6vectorIhNS1_9allocatorIhEEEE7uint256EEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEjEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIN6wallet10CMasterKeyEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE7CScriptEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEhEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS2_I7uint2567CPubKeyEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsIN6wallet16WalletDescriptorEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE7uint256EENS2_IjjEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS2_INS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE7uint256EEjEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS2_I22transaction_identifierILb0EEjEEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__14pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS2_IS8_S8_EEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI11ObfuscationEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsINSt3__16vectorISt4byteNS1_9allocatorIS3_EEEEEERS_RKT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_111DBHeightKeyEEERS_RKT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_19DBHashKeyEEERS_RKT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_15DBValEEERS_RKT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamlsINSt3__14pairI7uint256N12_GLOBAL__N_15DBValEEEEERS_RKT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_111DBHeightKeyEEERS_RKT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_19DBHashKeyEEERS_RKT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_15DBValEEERS_RKT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamlsINSt3__14pairI7uint256N12_GLOBAL__N_15DBValEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI10MuHash3072EERS_RKT__ZN10DataStreamlsINSt3__14pairIh7uint256EEEERS_RKT_| Line | Count | Source |  | 242 | 113k |     { |  | 243 | 113k |         ::Serialize(*this, obj); |  | 244 | 113k |         return (*this); |  | 245 | 113k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsI10CDiskTxPosEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI6CTxOutEERS_RKT__ZN10DataStreamlsINSt3__14pairIhiEEEERS_RKT_| Line | Count | Source |  | 242 | 104k |     { |  | 243 | 104k |         ::Serialize(*this, obj); |  | 244 | 104k |         return (*this); |  | 245 | 104k |     } | 
_ZN10DataStreamlsINSt3__14pairIhNS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEEEERS_RKT_| Line | Count | Source |  | 242 | 51.2k |     { |  | 243 | 51.2k |         ::Serialize(*this, obj); |  | 244 | 51.2k |         return (*this); |  | 245 | 51.2k |     } | 
Unexecuted instantiation: _ZN10DataStreamlsINSt3__16vectorI5CCoinNS1_9allocatorIS3_EEEEEERS_RKT_Unexecuted instantiation: _ZN10DataStreamlsI13ParamsWrapperI20TransactionSerParamsK6CBlockEEERS_RKT_txdb.cpp:_ZN10DataStreamlsIN12_GLOBAL__N_19CoinEntryEEERS_RKT_| Line | Count | Source |  | 242 | 1.54M |     { |  | 243 | 1.54M |         ::Serialize(*this, obj); |  | 244 | 1.54M |         return (*this); |  | 245 | 1.54M |     } | 
_ZN10DataStreamlsINSt3__16vectorI7uint256NS1_9allocatorIS3_EEEEEERS_RKT_| Line | Count | Source |  | 242 | 4.58k |     { |  | 243 | 4.58k |         ::Serialize(*this, obj); |  | 244 | 4.58k |         return (*this); |  | 245 | 4.58k |     } | 
 | 
| 246 |  |  | 
| 247 |  |     template <typename T> | 
| 248 |  |     DataStream& operator>>(T&& obj) | 
| 249 | 41.0M |     { | 
| 250 | 41.0M |         ::Unserialize(*this, obj); | 
| 251 | 41.0M |         return (*this); | 
| 252 | 41.0M |     } Unexecuted instantiation: _ZN10DataStreamrsIR20AddrManDeterministicEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperI20TransactionSerParams6CBlockEEERS_OT__ZN10DataStreamrsIR12CBlockHeaderEERS_OT_| Line | Count | Source |  | 249 | 723k |     { |  | 250 | 723k |         ::Unserialize(*this, obj); |  | 251 | 723k |         return (*this); |  | 252 | 723k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIR13CBlockLocatorEERS_OT__ZN10DataStreamrsIR14CBlockFileInfoEERS_OT_| Line | Count | Source |  | 249 | 51.2k |     { |  | 250 | 51.2k |         ::Unserialize(*this, obj); |  | 251 | 51.2k |         return (*this); |  | 252 | 51.2k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIR11BlockFilterEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRhEERS_OT__ZN10DataStreamrsIR7uint256EERS_OT_| Line | Count | Source |  | 249 | 107k |     { |  | 250 | 107k |         ::Unserialize(*this, obj); |  | 251 | 107k |         return (*this); |  | 252 | 107k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorIhNS1_9allocatorIhEEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR9COutPointEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperI20TransactionSerParams19CMutableTransactionEEERS_OT__ZN10DataStreamrsIR15CDiskBlockIndexEERS_OT_| Line | Count | Source |  | 249 | 10.3M |     { |  | 250 | 10.3M |         ::Unserialize(*this, obj); |  | 251 | 10.3M |         return (*this); |  | 252 | 10.3M |     } | 
_ZN10DataStreamrsIR4CoinEERS_OT_| Line | Count | Source |  | 249 | 1.34M |     { |  | 250 | 1.34M |         ::Unserialize(*this, obj); |  | 251 | 1.34M |         return (*this); |  | 252 | 1.34M |     } | 
_ZN10DataStreamrsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_OT_| Line | Count | Source |  | 249 | 1.34M |     { |  | 250 | 1.34M |         ::Unserialize(*this, obj); |  | 251 | 1.34M |         return (*this); |  | 252 | 1.34M |     } | 
_ZN10DataStreamrsI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS_OT_| Line | Count | Source |  | 249 | 1.34M |     { |  | 250 | 1.34M |         ::Unserialize(*this, obj); |  | 251 | 1.34M |         return (*this); |  | 252 | 1.34M |     } | 
_ZN10DataStreamrsINSt3__14spanIhLm18446744073709551615EEEEERS_OT_| Line | Count | Source |  | 249 | 1.34M |     { |  | 250 | 1.34M |         ::Unserialize(*this, obj); |  | 251 | 1.34M |         return (*this); |  | 252 | 1.34M |     } | 
Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperIN8CAddress9SerParamsE8AddrInfoEEERS_OT__ZN10DataStreamrsIR25CBlockHeaderAndShortTxIDsEERS_OT_| Line | Count | Source |  | 249 | 1.35M |     { |  | 250 | 1.35M |         ::Unserialize(*this, obj); |  | 251 | 1.35M |         return (*this); |  | 252 | 1.35M |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIR8CFeeRateEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR12CMerkleBlockEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR18CPartialMerkleTreeEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR7CPubKeyEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR7CScriptEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR5CTxInEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR11FlatFilePosEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR13KeyOriginInfoEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR26PartiallySignedTransactionEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRA5_hEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRA4_hEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRjEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR9PSBTInputEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__13setI7uint256NS1_4lessIS3_EENS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR10PSBTOutputEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR20PrefilledTransactionEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR13ParamsWrapperI20TransactionSerParams6CBlockEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR7CTxUndoEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR10CBlockUndoEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperIN8CNetAddr9SerParamsES2_EEERS_OT__ZN10DataStreamrsI13ParamsWrapperIN8CNetAddr9SerParamsE8CServiceEEERS_OT_| Line | Count | Source |  | 249 | 191k |     { |  | 250 | 191k |         ::Unserialize(*this, obj); |  | 251 | 191k |         return (*this); |  | 252 | 191k |     } | 
_ZN10DataStreamrsIR14CMessageHeaderEERS_OT_| Line | Count | Source |  | 249 | 6.84M |     { |  | 250 | 6.84M |         ::Unserialize(*this, obj); |  | 251 | 6.84M |         return (*this); |  | 252 | 6.84M |     } | 
Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperIN8CAddress9SerParamsES2_EEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR4CInvEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR12CBloomFilterEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR7WrapperI16TxOutCompressionR6CTxOutEEERS_OT__ZN10DataStreamrsIR17BlockTransactionsEERS_OT_| Line | Count | Source |  | 249 | 186k |     { |  | 250 | 186k |         ::Unserialize(*this, obj); |  | 251 | 186k |         return (*this); |  | 252 | 186k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIR24BlockTransactionsRequestEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRN4node16SnapshotMetadataEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__15arrayIhLm5EEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRtEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__15arrayIhLm4EEEEERS_OT__ZN10DataStreamrsIRyEERS_OT_| Line | Count | Source |  | 249 | 264k |     { |  | 250 | 264k |         ::Unserialize(*this, obj); |  | 251 | 264k |         return (*this); |  | 252 | 264k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIR7uint160EERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI12CBlockHeaderNS1_9allocatorIS3_EEEEEERS_OT__ZN10DataStreamrsIRxEERS_OT_| Line | Count | Source |  | 249 | 191k |     { |  | 250 | 191k |         ::Unserialize(*this, obj); |  | 251 | 191k |         return (*this); |  | 252 | 191k |     } | 
_ZN10DataStreamrsIRiEERS_OT_| Line | Count | Source |  | 249 | 434k |     { |  | 250 | 434k |         ::Unserialize(*this, obj); |  | 251 | 434k |         return (*this); |  | 252 | 434k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRsEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRaEERS_OT__ZN10DataStreamrsIRbEERS_OT_| Line | Count | Source |  | 249 | 264k |     { |  | 250 | 264k |         ::Unserialize(*this, obj); |  | 251 | 264k |         return (*this); |  | 252 | 264k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI5CTxInNS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI6CTxOutNS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorINS2_IhNS1_9allocatorIhEEEENS3_IS5_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR6CTxOutEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR7WrapperI22LimitedStringFormatterILm10EERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEERS_OT__ZN10DataStreamrsI13ParamsWrapperIN8CAddress9SerParamsE8CNetAddrEEERS_OT_| Line | Count | Source |  | 249 | 382k |     { |  | 250 | 382k |         ::Unserialize(*this, obj); |  | 251 | 382k |         return (*this); |  | 252 | 382k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRN6wallet12CKeyMetadataEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRN6wallet16WalletDescriptorEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR22transaction_identifierILb0EEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRN6wallet9CWalletTxEEERS_OT__ZN10DataStreamrsI13ParamsWrapperI20TransactionSerParamsNSt3__110shared_ptrIK12CTransactionEEEEERS_OT_| Line | Count | Source |  | 249 | 3.53M |     { |  | 250 | 3.53M |         ::Unserialize(*this, obj); |  | 251 | 3.53M |         return (*this); |  | 252 | 3.53M |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI7uint256NS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorIN6wallet9CMerkleTxENS1_9allocatorIS4_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__13mapINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES8_NS1_4lessIS8_EENS6_INS1_4pairIKS8_S8_EEEEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorINS1_4pairINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_EENS7_ISA_EEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorIh16secure_allocatorIhEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRN6wallet10CMasterKeyEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRN6wallet8CHDChainEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsI7WrapperI19CustomUintFormatterILi1ELb0EERN11AddrManImpl6FormatEEEERS_OT__ZN10DataStreamrsIR11ObfuscationEERS_OT_| Line | Count | Source |  | 249 | 51.2k |     { |  | 250 | 51.2k |         ::Unserialize(*this, obj); |  | 251 | 51.2k |         return (*this); |  | 252 | 51.2k |     } | 
_ZN10DataStreamrsIRNSt3__16vectorISt4byteNS1_9allocatorIS3_EEEEEERS_OT_| Line | Count | Source |  | 249 | 51.2k |     { |  | 250 | 51.2k |         ::Unserialize(*this, obj); |  | 251 | 51.2k |         return (*this); |  | 252 | 51.2k |     } | 
Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamrsIRN12_GLOBAL__N_111DBHeightKeyEEERS_OT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamrsIRNSt3__14pairI7uint256N12_GLOBAL__N_15DBValEEEEERS_OT_Unexecuted instantiation: blockfilterindex.cpp:_ZN10DataStreamrsIRN12_GLOBAL__N_15DBValEEERS_OT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamrsIRN12_GLOBAL__N_111DBHeightKeyEEERS_OT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamrsIRNSt3__14pairI7uint256N12_GLOBAL__N_15DBValEEEEERS_OT_Unexecuted instantiation: coinstatsindex.cpp:_ZN10DataStreamrsIRN12_GLOBAL__N_15DBValEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR10MuHash3072EERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIR10CDiskTxPosEERS_OT__ZN10DataStreamrsI7WrapperI19CustomUintFormatterILi8ELb0EER12ServiceFlagsEEERS_OT_| Line | Count | Source |  | 249 | 191k |     { |  | 250 | 191k |         ::Unserialize(*this, obj); |  | 251 | 191k |         return (*this); |  | 252 | 191k |     } | 
_ZN10DataStreamrsI7WrapperI22LimitedStringFormatterILm256EERNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEEERS_OT_| Line | Count | Source |  | 249 | 190k |     { |  | 250 | 190k |         ::Unserialize(*this, obj); |  | 251 | 190k |         return (*this); |  | 252 | 190k |     } | 
Unexecuted instantiation: _ZN10DataStreamrsI13ParamsWrapperIN8CAddress9SerParamsENSt3__16vectorIS2_NS4_9allocatorIS2_EEEEEEERS_OT_Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI4CInvNS1_9allocatorIS3_EEEEEERS_OT__ZN10DataStreamrsIRNSt3__14pairIh7uint256EEEERS_OT_| Line | Count | Source |  | 249 | 10.3M |     { |  | 250 | 10.3M |         ::Unserialize(*this, obj); |  | 251 | 10.3M |         return (*this); |  | 252 | 10.3M |     } | 
Unexecuted instantiation: _ZN10DataStreamrsIRNSt3__16vectorI9COutPointNS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: txdb.cpp:_ZN10DataStreamrsIRN12_GLOBAL__N_19CoinEntryEEERS_OT_ | 
| 253 |  |  | 
| 254 |  |     /** Compute total memory usage of this object (own memory + any dynamic memory). */ | 
| 255 |  |     size_t GetMemoryUsage() const noexcept; | 
| 256 |  | }; | 
| 257 |  |  | 
| 258 |  | template <typename IStream> | 
| 259 |  | class BitStreamReader | 
| 260 |  | { | 
| 261 |  | private: | 
| 262 |  |     IStream& m_istream; | 
| 263 |  |  | 
| 264 |  |     /// Buffered byte read in from the input stream. A new byte is read into the | 
| 265 |  |     /// buffer when m_offset reaches 8. | 
| 266 |  |     uint8_t m_buffer{0}; | 
| 267 |  |  | 
| 268 |  |     /// Number of high order bits in m_buffer already returned by previous | 
| 269 |  |     /// Read() calls. The next bit to be returned is at this offset from the | 
| 270 |  |     /// most significant bit position. | 
| 271 |  |     int m_offset{8}; | 
| 272 |  |  | 
| 273 |  | public: | 
| 274 | 0 |     explicit BitStreamReader(IStream& istream) : m_istream(istream) {} | 
| 275 |  |  | 
| 276 |  |     /** Read the specified number of bits from the stream. The data is returned | 
| 277 |  |      * in the nbits least significant bits of a 64-bit uint. | 
| 278 |  |      */ | 
| 279 | 0 |     uint64_t Read(int nbits) { | 
| 280 | 0 |         if (nbits < 0 || nbits > 64) { | 
| 281 | 0 |             throw std::out_of_range("nbits must be between 0 and 64"); | 
| 282 | 0 |         } | 
| 283 |  |  | 
| 284 | 0 |         uint64_t data = 0; | 
| 285 | 0 |         while (nbits > 0) { | 
| 286 | 0 |             if (m_offset == 8) { | 
| 287 | 0 |                 m_istream >> m_buffer; | 
| 288 | 0 |                 m_offset = 0; | 
| 289 | 0 |             } | 
| 290 |  | 
 | 
| 291 | 0 |             int bits = std::min(8 - m_offset, nbits); | 
| 292 | 0 |             data <<= bits; | 
| 293 | 0 |             data |= static_cast<uint8_t>(m_buffer << m_offset) >> (8 - bits); | 
| 294 | 0 |             m_offset += bits; | 
| 295 | 0 |             nbits -= bits; | 
| 296 | 0 |         } | 
| 297 | 0 |         return data; | 
| 298 | 0 |     } | 
| 299 |  | }; | 
| 300 |  |  | 
| 301 |  | template <typename OStream> | 
| 302 |  | class BitStreamWriter | 
| 303 |  | { | 
| 304 |  | private: | 
| 305 |  |     OStream& m_ostream; | 
| 306 |  |  | 
| 307 |  |     /// Buffered byte waiting to be written to the output stream. The byte is | 
| 308 |  |     /// written buffer when m_offset reaches 8 or Flush() is called. | 
| 309 |  |     uint8_t m_buffer{0}; | 
| 310 |  |  | 
| 311 |  |     /// Number of high order bits in m_buffer already written by previous | 
| 312 |  |     /// Write() calls and not yet flushed to the stream. The next bit to be | 
| 313 |  |     /// written to is at this offset from the most significant bit position. | 
| 314 |  |     int m_offset{0}; | 
| 315 |  |  | 
| 316 |  | public: | 
| 317 | 0 |     explicit BitStreamWriter(OStream& ostream) : m_ostream(ostream) {} | 
| 318 |  |  | 
| 319 |  |     ~BitStreamWriter() | 
| 320 | 0 |     { | 
| 321 | 0 |         Flush(); | 
| 322 | 0 |     } | 
| 323 |  |  | 
| 324 |  |     /** Write the nbits least significant bits of a 64-bit int to the output | 
| 325 |  |      * stream. Data is buffered until it completes an octet. | 
| 326 |  |      */ | 
| 327 | 0 |     void Write(uint64_t data, int nbits) { | 
| 328 | 0 |         if (nbits < 0 || nbits > 64) { | 
| 329 | 0 |             throw std::out_of_range("nbits must be between 0 and 64"); | 
| 330 | 0 |         } | 
| 331 |  |  | 
| 332 | 0 |         while (nbits > 0) { | 
| 333 | 0 |             int bits = std::min(8 - m_offset, nbits); | 
| 334 | 0 |             m_buffer |= (data << (64 - nbits)) >> (64 - 8 + m_offset); | 
| 335 | 0 |             m_offset += bits; | 
| 336 | 0 |             nbits -= bits; | 
| 337 |  | 
 | 
| 338 | 0 |             if (m_offset == 8) { | 
| 339 | 0 |                 Flush(); | 
| 340 | 0 |             } | 
| 341 | 0 |         } | 
| 342 | 0 |     } | 
| 343 |  |  | 
| 344 |  |     /** Flush any unwritten bits to the output stream, padding with 0's to the | 
| 345 |  |      * next byte boundary. | 
| 346 |  |      */ | 
| 347 | 0 |     void Flush() { | 
| 348 | 0 |         if (m_offset == 0) { | 
| 349 | 0 |             return; | 
| 350 | 0 |         } | 
| 351 |  |  | 
| 352 | 0 |         m_ostream << m_buffer; | 
| 353 | 0 |         m_buffer = 0; | 
| 354 | 0 |         m_offset = 0; | 
| 355 | 0 |     } | 
| 356 |  | }; | 
| 357 |  |  | 
| 358 |  | /** Non-refcounted RAII wrapper for FILE* | 
| 359 |  |  * | 
| 360 |  |  * Will automatically close the file when it goes out of scope if not null. | 
| 361 |  |  * If you're returning the file pointer, return file.release(). | 
| 362 |  |  * If you need to close the file early, use autofile.fclose() instead of fclose(underlying_FILE). | 
| 363 |  |  * | 
| 364 |  |  * @note If the file has been written to, then the caller must close it | 
| 365 |  |  * explicitly with the `fclose()` method, check if it returns an error and treat | 
| 366 |  |  * such an error as if the `write()` method failed. The OS's `fclose(3)` may | 
| 367 |  |  * fail to flush to disk data that has been previously written, rendering the | 
| 368 |  |  * file corrupt. | 
| 369 |  |  */ | 
| 370 |  | class AutoFile | 
| 371 |  | { | 
| 372 |  | protected: | 
| 373 |  |     std::FILE* m_file; | 
| 374 |  |     Obfuscation m_obfuscation; | 
| 375 |  |     std::optional<int64_t> m_position; | 
| 376 |  |     bool m_was_written{false}; | 
| 377 |  |  | 
| 378 |  | public: | 
| 379 |  |     explicit AutoFile(std::FILE* file, const Obfuscation& obfuscation = {}); | 
| 380 |  |  | 
| 381 |  |     ~AutoFile() | 
| 382 | 1.07M |     { | 
| 383 | 1.07M |         if (m_was_written) { | 
| 384 |  |             // Callers that wrote to the file must have closed it explicitly | 
| 385 |  |             // with the fclose() method and checked that the close succeeded. | 
| 386 |  |             // This is because here in the destructor we have no way to signal | 
| 387 |  |             // errors from fclose() which, after write, could mean the file is | 
| 388 |  |             // corrupted and must be handled properly at the call site. | 
| 389 |  |             // Destructors in C++ cannot signal an error to the callers because | 
| 390 |  |             // they do not return a value and are not allowed to throw exceptions. | 
| 391 | 50.0k |             Assume(IsNull()); | Line | Count | Source |  | 118 | 50.0k | #define Assume(val) inline_assertion_check<false>(val, __FILE__, __LINE__, __func__, #val) | 
 | 
| 392 | 50.0k |         } | 
| 393 |  |  | 
| 394 | 1.07M |         if (fclose() != 0) { | 
| 395 | 0 |             LogError("Failed to close file: %s", SysErrorString(errno));| Line | Count | Source |  | 358 | 0 | #define LogError(...) LogPrintLevel_(BCLog::LogFlags::ALL, BCLog::Level::Error, /*should_ratelimit=*/true, __VA_ARGS__) | Line | Count | Source |  | 350 | 0 | #define LogPrintLevel_(category, level, should_ratelimit, ...) LogPrintFormatInternal(std::source_location::current(), category, level, should_ratelimit, __VA_ARGS__) | 
 | 
 | 
| 396 | 0 |         } | 
| 397 | 1.07M |     } | 
| 398 |  |  | 
| 399 |  |     // Disallow copies | 
| 400 |  |     AutoFile(const AutoFile&) = delete; | 
| 401 |  |     AutoFile& operator=(const AutoFile&) = delete; | 
| 402 |  |  | 
| 403 | 0 |     bool feof() const { return std::feof(m_file); } | 
| 404 |  |  | 
| 405 |  |     [[nodiscard]] int fclose() | 
| 406 | 1.12M |     { | 
| 407 | 1.12M |         if (auto rel{release()}) return std::fclose(rel)1.07M; | 
| 408 | 50.0k |         return 0; | 
| 409 | 1.12M |     } | 
| 410 |  |  | 
| 411 |  |     /** Get wrapped FILE* with transfer of ownership. | 
| 412 |  |      * @note This will invalidate the AutoFile object, and makes it the responsibility of the caller | 
| 413 |  |      * of this function to clean up the returned FILE*. | 
| 414 |  |      */ | 
| 415 |  |     std::FILE* release() | 
| 416 | 1.12M |     { | 
| 417 | 1.12M |         std::FILE* ret{m_file}; | 
| 418 | 1.12M |         m_file = nullptr; | 
| 419 | 1.12M |         return ret; | 
| 420 | 1.12M |     } | 
| 421 |  |  | 
| 422 |  |     /** Return true if the wrapped FILE* is nullptr, false otherwise. | 
| 423 |  |      */ | 
| 424 | 2.15M |     bool IsNull() const { return m_file == nullptr; } | 
| 425 |  |  | 
| 426 |  |     /** Continue with a different XOR key */ | 
| 427 | 0 |     void SetObfuscation(const Obfuscation& obfuscation) { m_obfuscation = obfuscation; } | 
| 428 |  |  | 
| 429 |  |     /** Implementation detail, only used internally. */ | 
| 430 |  |     std::size_t detail_fread(std::span<std::byte> dst); | 
| 431 |  |  | 
| 432 |  |     /** Wrapper around fseek(). Will throw if seeking is not possible. */ | 
| 433 |  |     void seek(int64_t offset, int origin); | 
| 434 |  |  | 
| 435 |  |     /** Find position within the file. Will throw if unknown. */ | 
| 436 |  |     int64_t tell(); | 
| 437 |  |  | 
| 438 |  |     /** Wrapper around FileCommit(). */ | 
| 439 |  |     bool Commit(); | 
| 440 |  |  | 
| 441 |  |     /** Wrapper around TruncateFile(). */ | 
| 442 |  |     bool Truncate(unsigned size); | 
| 443 |  |  | 
| 444 |  |     //! Write a mutable buffer more efficiently than write(), obfuscating the buffer in-place. | 
| 445 |  |     void write_buffer(std::span<std::byte> src); | 
| 446 |  |  | 
| 447 |  |     // | 
| 448 |  |     // Stream subset | 
| 449 |  |     // | 
| 450 |  |     void read(std::span<std::byte> dst); | 
| 451 |  |     void ignore(size_t nSize); | 
| 452 |  |     void write(std::span<const std::byte> src); | 
| 453 |  |  | 
| 454 |  |     template <typename T> | 
| 455 |  |     AutoFile& operator<<(const T& obj) | 
| 456 | 0 |     { | 
| 457 | 0 |         ::Serialize(*this, obj); | 
| 458 | 0 |         return *this; | 
| 459 | 0 |     } Unexecuted instantiation: _ZN8AutoFilelsIbEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIaEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIhEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIsEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsItEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIiEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIjEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIxEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIyEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__16vectorIhNS1_9allocatorIhEEEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__14spanIhLm18446744073709551615EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsIN4node16SnapshotMetadataEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__15arrayIhLm5EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__15arrayIhLm4EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI7uint256EERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__14spanIKhLm32EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI22transaction_identifierILb0EEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI4CoinEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__14spanIKhLm18446744073709551615EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__14spanIKcLm18446744073709551615EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__15arrayISt4byteLm8EEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI11ObfuscationEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__16vectorISt4byteNS1_9allocatorIS3_EEEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsI13ParamsWrapperI20TransactionSerParamsK12CTransactionEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__13mapI22transaction_identifierILb0EExNS1_4lessIS4_EENS1_9allocatorINS1_4pairIKS4_xEEEEEEEERS_RKT_Unexecuted instantiation: _ZN8AutoFilelsINSt3__13setI22transaction_identifierILb0EENS1_4lessIS4_EENS1_9allocatorIS4_EEEEEERS_RKT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilelsI7WrapperIN12_GLOBAL__N_122EncodedDoubleFormatterERKdEEERS_RKT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilelsI7WrapperI15VectorFormatterIN12_GLOBAL__N_122EncodedDoubleFormatterEERKNSt3__16vectorIdNS6_9allocatorIdEEEEEEERS_RKT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilelsI7WrapperI15VectorFormatterIS2_IN12_GLOBAL__N_122EncodedDoubleFormatterEEERKNSt3__16vectorINS8_IdNS7_9allocatorIdEEEENS9_ISB_EEEEEEERS_RKT_ | 
| 460 |  |  | 
| 461 |  |     template <typename T> | 
| 462 |  |     AutoFile& operator>>(T&& obj) | 
| 463 | 668k |     { | 
| 464 | 668k |         ::Unserialize(*this, obj); | 
| 465 | 668k |         return *this; | 
| 466 | 668k |     } Unexecuted instantiation: _ZN8AutoFilersIRbEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRaEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRhEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRsEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRtEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRiEERS_OT__ZN8AutoFilersIRjEERS_OT_| Line | Count | Source |  | 463 | 308k |     { |  | 464 | 308k |         ::Unserialize(*this, obj); |  | 465 | 308k |         return *this; |  | 466 | 308k |     } | 
Unexecuted instantiation: _ZN8AutoFilersIRxEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRyEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__16vectorIhNS1_9allocatorIhEEEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN4node16SnapshotMetadataEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__15arrayIhLm5EEEEERS_OT__ZN8AutoFilersIRNSt3__15arrayIhLm4EEEEERS_OT_| Line | Count | Source |  | 463 | 308k |     { |  | 464 | 308k |         ::Unserialize(*this, obj); |  | 465 | 308k |         return *this; |  | 466 | 308k |     } | 
Unexecuted instantiation: _ZN8AutoFilersIR7uint256EERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet8MetaPageEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__15arrayISt4byteLm20EEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRA368_cEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRA12_cEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRA20_hEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRA16_hEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet10PageHeaderEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet11RecordsPageEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet12RecordHeaderEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet10DataRecordEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet14OverflowRecordEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet12InternalPageEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet14InternalRecordEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRN6wallet12OverflowPageEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersI7WrapperI19CustomUintFormatterILi1ELb0EERN11AddrManImpl6FormatEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIR12CBlockHeaderEERS_OT_Unexecuted instantiation: _ZN8AutoFilersI13ParamsWrapperI20TransactionSerParamsNSt3__110shared_ptrIK12CTransactionEEEEERS_OT__ZN8AutoFilersIRNSt3__15arrayISt4byteLm8EEEEERS_OT_| Line | Count | Source |  | 463 | 51.2k |     { |  | 464 | 51.2k |         ::Unserialize(*this, obj); |  | 465 | 51.2k |         return *this; |  | 466 | 51.2k |     } | 
Unexecuted instantiation: _ZN8AutoFilersIR11ObfuscationEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__16vectorISt4byteNS1_9allocatorIS3_EEEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__13mapI22transaction_identifierILb0EExNS1_4lessIS4_EENS1_9allocatorINS1_4pairIKS4_xEEEEEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRNSt3__13setI22transaction_identifierILb0EENS1_4lessIS4_EENS1_9allocatorIS4_EEEEEERS_OT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilersI7WrapperIN12_GLOBAL__N_122EncodedDoubleFormatterERdEEERS_OT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilersI7WrapperI15VectorFormatterIN12_GLOBAL__N_122EncodedDoubleFormatterEERNSt3__16vectorIdNS6_9allocatorIdEEEEEEERS_OT_Unexecuted instantiation: fees.cpp:_ZN8AutoFilersI7WrapperI15VectorFormatterIS2_IN12_GLOBAL__N_122EncodedDoubleFormatterEEERNSt3__16vectorINS8_IdNS7_9allocatorIdEEEENS9_ISB_EEEEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIR22transaction_identifierILb0EEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIR4CoinEERS_OT_Unexecuted instantiation: _ZN8AutoFilersI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersINSt3__14spanIhLm18446744073709551615EEEEERS_OT_Unexecuted instantiation: _ZN8AutoFilersIRSt4byteEERS_OT_ | 
| 467 |  | }; | 
| 468 |  |  | 
| 469 |  | using DataBuffer = std::vector<std::byte>; | 
| 470 |  |  | 
| 471 |  | /** Wrapper around an AutoFile& that implements a ring buffer to | 
| 472 |  |  *  deserialize from. It guarantees the ability to rewind a given number of bytes. | 
| 473 |  |  * | 
| 474 |  |  *  Will automatically close the file when it goes out of scope if not null. | 
| 475 |  |  *  If you need to close the file early, use file.fclose() instead of fclose(file). | 
| 476 |  |  */ | 
| 477 |  | class BufferedFile | 
| 478 |  | { | 
| 479 |  | private: | 
| 480 |  |     AutoFile& m_src; | 
| 481 |  |     uint64_t nSrcPos{0};  //!< how many bytes have been read from source | 
| 482 |  |     uint64_t m_read_pos{0}; //!< how many bytes have been read from this | 
| 483 |  |     uint64_t nReadLimit;  //!< up to which position we're allowed to read | 
| 484 |  |     uint64_t nRewind;     //!< how many bytes we guarantee to rewind | 
| 485 |  |     DataBuffer vchBuf; | 
| 486 |  |  | 
| 487 |  |     //! read data from the source to fill the buffer | 
| 488 | 0 |     bool Fill() { | 
| 489 | 0 |         unsigned int pos = nSrcPos % vchBuf.size(); | 
| 490 | 0 |         unsigned int readNow = vchBuf.size() - pos; | 
| 491 | 0 |         unsigned int nAvail = vchBuf.size() - (nSrcPos - m_read_pos) - nRewind; | 
| 492 | 0 |         if (nAvail < readNow) | 
| 493 | 0 |             readNow = nAvail; | 
| 494 | 0 |         if (readNow == 0) | 
| 495 | 0 |             return false; | 
| 496 | 0 |         size_t nBytes{m_src.detail_fread(std::span{vchBuf}.subspan(pos, readNow))}; | 
| 497 | 0 |         if (nBytes == 0) { | 
| 498 | 0 |             throw std::ios_base::failure{m_src.feof() ? "BufferedFile::Fill: end of file" : "BufferedFile::Fill: fread failed"}; | 
| 499 | 0 |         } | 
| 500 | 0 |         nSrcPos += nBytes; | 
| 501 | 0 |         return true; | 
| 502 | 0 |     } | 
| 503 |  |  | 
| 504 |  |     //! Advance the stream's read pointer (m_read_pos) by up to 'length' bytes, | 
| 505 |  |     //! filling the buffer from the file so that at least one byte is available. | 
| 506 |  |     //! Return a pointer to the available buffer data and the number of bytes | 
| 507 |  |     //! (which may be less than the requested length) that may be accessed | 
| 508 |  |     //! beginning at that pointer. | 
| 509 |  |     std::pair<std::byte*, size_t> AdvanceStream(size_t length) | 
| 510 | 0 |     { | 
| 511 | 0 |         assert(m_read_pos <= nSrcPos); | 
| 512 | 0 |         if (m_read_pos + length > nReadLimit) { | 
| 513 | 0 |             throw std::ios_base::failure("Attempt to position past buffer limit"); | 
| 514 | 0 |         } | 
| 515 |  |         // If there are no bytes available, read from the file. | 
| 516 | 0 |         if (m_read_pos == nSrcPos && length > 0) Fill(); | 
| 517 |  | 
 | 
| 518 | 0 |         size_t buffer_offset{static_cast<size_t>(m_read_pos % vchBuf.size())}; | 
| 519 | 0 |         size_t buffer_available{static_cast<size_t>(vchBuf.size() - buffer_offset)}; | 
| 520 | 0 |         size_t bytes_until_source_pos{static_cast<size_t>(nSrcPos - m_read_pos)}; | 
| 521 | 0 |         size_t advance{std::min({length, buffer_available, bytes_until_source_pos})}; | 
| 522 | 0 |         m_read_pos += advance; | 
| 523 | 0 |         return std::make_pair(&vchBuf[buffer_offset], advance); | 
| 524 | 0 |     } | 
| 525 |  |  | 
| 526 |  | public: | 
| 527 |  |     BufferedFile(AutoFile& file LIFETIMEBOUND, uint64_t nBufSize, uint64_t nRewindIn) | 
| 528 | 0 |         : m_src{file}, nReadLimit{std::numeric_limits<uint64_t>::max()}, nRewind{nRewindIn}, vchBuf(nBufSize, std::byte{0}) | 
| 529 | 0 |     { | 
| 530 | 0 |         if (nRewindIn >= nBufSize) | 
| 531 | 0 |             throw std::ios_base::failure("Rewind limit must be less than buffer size"); | 
| 532 | 0 |     } | 
| 533 |  |  | 
| 534 |  |     //! check whether we're at the end of the source file | 
| 535 | 0 |     bool eof() const { | 
| 536 | 0 |         return m_read_pos == nSrcPos && m_src.feof(); | 
| 537 | 0 |     } | 
| 538 |  |  | 
| 539 |  |     //! read a number of bytes | 
| 540 |  |     void read(std::span<std::byte> dst) | 
| 541 | 0 |     { | 
| 542 | 0 |         while (dst.size() > 0) { | 
| 543 | 0 |             auto [buffer_pointer, length]{AdvanceStream(dst.size())}; | 
| 544 | 0 |             memcpy(dst.data(), buffer_pointer, length); | 
| 545 | 0 |             dst = dst.subspan(length); | 
| 546 | 0 |         } | 
| 547 | 0 |     } | 
| 548 |  |  | 
| 549 |  |     //! Move the read position ahead in the stream to the given position. | 
| 550 |  |     //! Use SetPos() to back up in the stream, not SkipTo(). | 
| 551 |  |     void SkipTo(const uint64_t file_pos) | 
| 552 | 0 |     { | 
| 553 | 0 |         assert(file_pos >= m_read_pos); | 
| 554 | 0 |         while (m_read_pos < file_pos) AdvanceStream(file_pos - m_read_pos); | 
| 555 | 0 |     } | 
| 556 |  |  | 
| 557 |  |     //! return the current reading position | 
| 558 | 0 |     uint64_t GetPos() const { | 
| 559 | 0 |         return m_read_pos; | 
| 560 | 0 |     } | 
| 561 |  |  | 
| 562 |  |     //! rewind to a given reading position | 
| 563 | 0 |     bool SetPos(uint64_t nPos) { | 
| 564 | 0 |         size_t bufsize = vchBuf.size(); | 
| 565 | 0 |         if (nPos + bufsize < nSrcPos) { | 
| 566 |  |             // rewinding too far, rewind as far as possible | 
| 567 | 0 |             m_read_pos = nSrcPos - bufsize; | 
| 568 | 0 |             return false; | 
| 569 | 0 |         } | 
| 570 | 0 |         if (nPos > nSrcPos) { | 
| 571 |  |             // can't go this far forward, go as far as possible | 
| 572 | 0 |             m_read_pos = nSrcPos; | 
| 573 | 0 |             return false; | 
| 574 | 0 |         } | 
| 575 | 0 |         m_read_pos = nPos; | 
| 576 | 0 |         return true; | 
| 577 | 0 |     } | 
| 578 |  |  | 
| 579 |  |     //! prevent reading beyond a certain position | 
| 580 |  |     //! no argument removes the limit | 
| 581 | 0 |     bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) { | 
| 582 | 0 |         if (nPos < m_read_pos) | 
| 583 | 0 |             return false; | 
| 584 | 0 |         nReadLimit = nPos; | 
| 585 | 0 |         return true; | 
| 586 | 0 |     } | 
| 587 |  |  | 
| 588 |  |     template<typename T> | 
| 589 | 0 |     BufferedFile& operator>>(T&& obj) { | 
| 590 | 0 |         ::Unserialize(*this, obj); | 
| 591 | 0 |         return (*this); | 
| 592 | 0 |     } Unexecuted instantiation: _ZN12BufferedFilersIRbEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRaEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRhEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRsEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRtEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRiEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRjEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRxEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRyEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRNSt3__16vectorIhNS1_9allocatorIhEEEEEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIRNSt3__15arrayIhLm4EEEEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersIR12CBlockHeaderEERS_OT_Unexecuted instantiation: _ZN12BufferedFilersI13ParamsWrapperI20TransactionSerParams6CBlockEEERS_OT_ | 
| 593 |  |  | 
| 594 |  |     //! search for a given byte in the stream, and remain positioned on it | 
| 595 |  |     void FindByte(std::byte byte) | 
| 596 | 0 |     { | 
| 597 |  |         // For best performance, avoid mod operation within the loop. | 
| 598 | 0 |         size_t buf_offset{size_t(m_read_pos % uint64_t(vchBuf.size()))}; | 
| 599 | 0 |         while (true) { | 
| 600 | 0 |             if (m_read_pos == nSrcPos) { | 
| 601 |  |                 // No more bytes available; read from the file into the buffer, | 
| 602 |  |                 // setting nSrcPos to one beyond the end of the new data. | 
| 603 |  |                 // Throws exception if end-of-file reached. | 
| 604 | 0 |                 Fill(); | 
| 605 | 0 |             } | 
| 606 | 0 |             const size_t len{std::min<size_t>(vchBuf.size() - buf_offset, nSrcPos - m_read_pos)}; | 
| 607 | 0 |             const auto it_start{vchBuf.begin() + buf_offset}; | 
| 608 | 0 |             const auto it_find{std::find(it_start, it_start + len, byte)}; | 
| 609 | 0 |             const size_t inc{size_t(std::distance(it_start, it_find))}; | 
| 610 | 0 |             m_read_pos += inc; | 
| 611 | 0 |             if (inc < len) break; | 
| 612 | 0 |             buf_offset += inc; | 
| 613 | 0 |             if (buf_offset >= vchBuf.size()) buf_offset = 0; | 
| 614 | 0 |         } | 
| 615 | 0 |     } | 
| 616 |  | }; | 
| 617 |  |  | 
| 618 |  | /** | 
| 619 |  |  * Wrapper that buffers reads from an underlying stream. | 
| 620 |  |  * Requires underlying stream to support read() and detail_fread() calls | 
| 621 |  |  * to support fixed-size and variable-sized reads, respectively. | 
| 622 |  |  */ | 
| 623 |  | template <typename S> | 
| 624 |  | class BufferedReader | 
| 625 |  | { | 
| 626 |  |     S& m_src; | 
| 627 |  |     DataBuffer m_buf; | 
| 628 |  |     size_t m_buf_pos; | 
| 629 |  |  | 
| 630 |  | public: | 
| 631 |  |     //! Requires stream ownership to prevent leaving the stream at an unexpected position after buffered reads. | 
| 632 |  |     explicit BufferedReader(S&& stream LIFETIMEBOUND, size_t size = 1 << 16) | 
| 633 |  |         requires std::is_rvalue_reference_v<S&&> | 
| 634 | 615k |         : m_src{stream}, m_buf(size), m_buf_pos{size} {} | 
| 635 |  |  | 
| 636 |  |     void read(std::span<std::byte> dst) | 
| 637 | 1.23M |     { | 
| 638 | 1.23M |         if (const auto available{std::min(dst.size(), m_buf.size() - m_buf_pos)}) { | 
| 639 | 615k |             std::copy_n(m_buf.begin() + m_buf_pos, available, dst.begin()); | 
| 640 | 615k |             m_buf_pos += available; | 
| 641 | 615k |             dst = dst.subspan(available); | 
| 642 | 615k |         } | 
| 643 | 1.23M |         if (dst.size()) { | 
| 644 | 615k |             assert(m_buf_pos == m_buf.size()); | 
| 645 | 615k |             m_src.read(dst); | 
| 646 |  |  | 
| 647 | 615k |             m_buf_pos = 0; | 
| 648 | 615k |             m_buf.resize(m_src.detail_fread(m_buf)); | 
| 649 | 615k |         } | 
| 650 | 1.23M |     } | 
| 651 |  |  | 
| 652 |  |     template <typename T> | 
| 653 |  |     BufferedReader& operator>>(T&& obj) | 
| 654 | 615k |     { | 
| 655 | 615k |         Unserialize(*this, obj); | 
| 656 | 615k |         return *this; | 
| 657 | 615k |     } | 
| 658 |  | }; | 
| 659 |  |  | 
| 660 |  | /** | 
| 661 |  |  * Wrapper that buffers writes to an underlying stream. | 
| 662 |  |  * Requires underlying stream to support write_buffer() method | 
| 663 |  |  * for efficient buffer flushing and obfuscation. | 
| 664 |  |  */ | 
| 665 |  | template <typename S> | 
| 666 |  | class BufferedWriter | 
| 667 |  | { | 
| 668 |  |     S& m_dst; | 
| 669 |  |     DataBuffer m_buf; | 
| 670 |  |     size_t m_buf_pos{0}; | 
| 671 |  |  | 
| 672 |  | public: | 
| 673 | 50.0k |     explicit BufferedWriter(S& stream LIFETIMEBOUND, size_t size = 1 << 16) : m_dst{stream}, m_buf(size) {} | 
| 674 |  |  | 
| 675 | 50.0k |     ~BufferedWriter() { flush(); } | 
| 676 |  |  | 
| 677 |  |     void flush() | 
| 678 | 50.0k |     { | 
| 679 | 50.0k |         if (m_buf_pos) m_dst.write_buffer(std::span{m_buf}.first(m_buf_pos)); | 
| 680 | 50.0k |         m_buf_pos = 0; | 
| 681 | 50.0k |     } | 
| 682 |  |  | 
| 683 |  |     void write(std::span<const std::byte> src) | 
| 684 | 3.92M |     { | 
| 685 | 7.85M |         while (const auto available{std::min(src.size(), m_buf.size() - m_buf_pos)}) { | 
| 686 | 3.92M |             std::copy_n(src.begin(), available, m_buf.begin() + m_buf_pos); | 
| 687 | 3.92M |             m_buf_pos += available; | 
| 688 | 3.92M |             if (m_buf_pos == m_buf.size()) flush()0; | 
| 689 | 3.92M |             src = src.subspan(available); | 
| 690 | 3.92M |         } | 
| 691 | 3.92M |     } | 
| 692 |  |  | 
| 693 |  |     template <typename T> | 
| 694 |  |     BufferedWriter& operator<<(const T& obj) | 
| 695 | 508k |     { | 
| 696 | 508k |         Serialize(*this, obj); | 
| 697 | 508k |         return *this; | 
| 698 | 508k |     } _ZN14BufferedWriterI8AutoFileElsINSt3__15arrayIhLm4EEEEERS1_RKT_| Line | Count | Source |  | 695 | 50.0k |     { |  | 696 | 50.0k |         Serialize(*this, obj); |  | 697 | 50.0k |         return *this; |  | 698 | 50.0k |     } | 
_ZN14BufferedWriterI8AutoFileElsIjEERS1_RKT_| Line | Count | Source |  | 695 | 50.0k |     { |  | 696 | 50.0k |         Serialize(*this, obj); |  | 697 | 50.0k |         return *this; |  | 698 | 50.0k |     } | 
_ZN14BufferedWriterI8AutoFileElsI10CBlockUndoEERS1_RKT_| Line | Count | Source |  | 695 | 21.7k |     { |  | 696 | 21.7k |         Serialize(*this, obj); |  | 697 | 21.7k |         return *this; |  | 698 | 21.7k |     } | 
_ZN14BufferedWriterI8AutoFileElsI7WrapperI15VarIntFormatterIL10VarIntMode0EERyEEERS1_RKT_| Line | Count | Source |  | 695 | 104k |     { |  | 696 | 104k |         Serialize(*this, obj); |  | 697 | 104k |         return *this; |  | 698 | 104k |     } | 
Unexecuted instantiation: _ZN14BufferedWriterI8AutoFileElsINSt3__14spanIhLm18446744073709551615EEEEERS1_RKT__ZN14BufferedWriterI8AutoFileElsI7WrapperI15VarIntFormatterIL10VarIntMode0EERjEEERS1_RKT_| Line | Count | Source |  | 695 | 104k |     { |  | 696 | 104k |         Serialize(*this, obj); |  | 697 | 104k |         return *this; |  | 698 | 104k |     } | 
_ZN14BufferedWriterI8AutoFileElsINSt3__14spanIKhLm18446744073709551615EEEEERS1_RKT_| Line | Count | Source |  | 695 | 104k |     { |  | 696 | 104k |         Serialize(*this, obj); |  | 697 | 104k |         return *this; |  | 698 | 104k |     } | 
_ZN14BufferedWriterI8AutoFileElsI7uint256EERS1_RKT_| Line | Count | Source |  | 695 | 21.7k |     { |  | 696 | 21.7k |         Serialize(*this, obj); |  | 697 | 21.7k |         return *this; |  | 698 | 21.7k |     } | 
_ZN14BufferedWriterI8AutoFileElsINSt3__14spanIKhLm32EEEEERS1_RKT_| Line | Count | Source |  | 695 | 21.7k |     { |  | 696 | 21.7k |         Serialize(*this, obj); |  | 697 | 21.7k |         return *this; |  | 698 | 21.7k |     } | 
_ZN14BufferedWriterI8AutoFileElsI13ParamsWrapperI20TransactionSerParamsK6CBlockEEERS1_RKT_| Line | Count | Source |  | 695 | 28.2k |     { |  | 696 | 28.2k |         Serialize(*this, obj); |  | 697 | 28.2k |         return *this; |  | 698 | 28.2k |     } | 
 | 
| 699 |  | }; | 
| 700 |  |  | 
| 701 |  | #endif // BITCOIN_STREAMS_H |