/tmp/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/check.h> |
13 | | #include <util/log.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 | 340k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn) : vchData{vchDataIn}, nPos{nPosIn} |
43 | 340k | { |
44 | 340k | if(nPos > vchData.size()) |
45 | 1 | vchData.resize(nPos); |
46 | 340k | } |
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 | 321k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} |
53 | 321k | { |
54 | 321k | ::SerializeMany(*this, std::forward<Args>(args)...); |
55 | 321k | } VectorWriter::VectorWriter<int const&, unsigned long const&, long const&, unsigned long const&, ParamsWrapper<CAddress::SerParams, CService const>>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, int const&, unsigned long const&, long const&, unsigned long const&, ParamsWrapper<CAddress::SerParams, CService const>&&) Line | Count | Source | 52 | 1 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 1 | { | 54 | 1 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 1 | } |
VectorWriter::VectorWriter<unsigned char&, unsigned char&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, unsigned char&, unsigned char&) Line | Count | Source | 52 | 10 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 10 | { | 54 | 10 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 10 | } |
VectorWriter::VectorWriter<unsigned char (&) [4]>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, unsigned char (&) [4]) Line | Count | Source | 52 | 2 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 2 | { | 54 | 2 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 2 | } |
VectorWriter::VectorWriter<unsigned char&, unsigned char (&) [4], unsigned char&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, unsigned char&, unsigned char (&) [4], unsigned char&) Line | Count | Source | 52 | 2 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 2 | { | 54 | 2 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 2 | } |
VectorWriter::VectorWriter<int&, Wrapper<CustomUintFormatter<8, false>, ServiceFlags&>, long, long, ParamsWrapper<CNetAddr::SerParams, CService>, long, ParamsWrapper<CNetAddr::SerParams, CService>, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, bool&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, int&, Wrapper<CustomUintFormatter<8, false>, ServiceFlags&>&&, long&&, long&&, ParamsWrapper<CNetAddr::SerParams, CService>&&, long&&, ParamsWrapper<CNetAddr::SerParams, CService>&&, unsigned long&&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&&, int&&, bool&) Line | Count | Source | 52 | 2 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 2 | { | 54 | 2 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 2 | } |
VectorWriter::VectorWriter<CMessageHeader&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, CMessageHeader&) Line | Count | Source | 52 | 160k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 160k | { | 54 | 160k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 160k | } |
VectorWriter::VectorWriter<bool, unsigned long const&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, bool&&, unsigned long const&) Line | Count | Source | 52 | 1.81k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 1.81k | { | 54 | 1.81k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 1.81k | } |
VectorWriter::VectorWriter<CBlockHeaderAndShortTxIDs const&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, CBlockHeaderAndShortTxIDs const&) Line | Count | Source | 52 | 17.0k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 17.0k | { | 54 | 17.0k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 17.0k | } |
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 | 52 | 65.8k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 65.8k | { | 54 | 65.8k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 65.8k | } |
VectorWriter::VectorWriter<ParamsWrapper<TransactionSerParams, CTransaction const>>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, ParamsWrapper<TransactionSerParams, CTransaction const>&&) Line | Count | Source | 52 | 13.2k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 13.2k | { | 54 | 13.2k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 13.2k | } |
VectorWriter::VectorWriter<std::span<std::byte const, 18446744073709551615ul>>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, std::span<std::byte const, 18446744073709551615ul>&&) Line | Count | Source | 52 | 27.9k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 27.9k | { | 54 | 27.9k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 27.9k | } |
VectorWriter::VectorWriter<ParamsWrapper<TransactionSerParams, CBlock const>>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, ParamsWrapper<TransactionSerParams, CBlock const>&&) Line | Count | Source | 52 | 8.34k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 8.34k | { | 54 | 8.34k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 8.34k | } |
VectorWriter::VectorWriter<CMerkleBlock&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, CMerkleBlock&) Line | Count | Source | 52 | 4 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 4 | { | 54 | 4 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 4 | } |
VectorWriter::VectorWriter<CBlockHeaderAndShortTxIDs&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, CBlockHeaderAndShortTxIDs&) Line | Count | Source | 52 | 1.62k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 1.62k | { | 54 | 1.62k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 1.62k | } |
VectorWriter::VectorWriter<int const&, unsigned long&, long&, 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&, bool&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, int const&, unsigned long&, long&, 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&, bool&) Line | Count | Source | 52 | 1.55k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 1.55k | { | 54 | 1.55k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 1.55k | } |
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 | 52 | 8 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 8 | { | 54 | 8 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 8 | } |
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<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 | 52 | 10 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 10 | { | 54 | 10 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 10 | } |
VectorWriter::VectorWriter<CBlockLocator const&, uint256>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, CBlockLocator const&, uint256&&) Line | Count | Source | 52 | 3.31k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 3.31k | { | 54 | 3.31k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 3.31k | } |
VectorWriter::VectorWriter<BlockTransactions&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, BlockTransactions&) Line | Count | Source | 52 | 610 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 610 | { | 54 | 610 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 610 | } |
VectorWriter::VectorWriter<std::vector<CBlockHeader, std::allocator<CBlockHeader>>>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, std::vector<CBlockHeader, std::allocator<CBlockHeader>>&&) Line | Count | Source | 52 | 9 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 9 | { | 54 | 9 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 9 | } |
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 | 52 | 6.62k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 6.62k | { | 54 | 6.62k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 6.62k | } |
VectorWriter::VectorWriter<BlockTransactionsRequest&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, BlockTransactionsRequest&) Line | Count | Source | 52 | 597 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 597 | { | 54 | 597 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 597 | } |
VectorWriter::VectorWriter<unsigned long&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, unsigned long&) Line | Count | Source | 52 | 10.2k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 10.2k | { | 54 | 10.2k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 10.2k | } |
VectorWriter::VectorWriter<BlockFilter const&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, BlockFilter const&) Line | Count | Source | 52 | 11 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 11 | { | 54 | 11 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 11 | } |
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>>&) Line | Count | Source | 52 | 2 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 2 | { | 54 | 2 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 2 | } |
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>>&) Line | Count | Source | 52 | 3 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 3 | { | 54 | 3 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 3 | } |
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 | 52 | 133 | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 133 | { | 54 | 133 | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 133 | } |
VectorWriter::VectorWriter<long&>(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, long&) Line | Count | Source | 52 | 1.67k | VectorWriter(std::vector<unsigned char>& vchDataIn, size_t nPosIn, Args&&... args) : VectorWriter{vchDataIn, nPosIn} | 53 | 1.67k | { | 54 | 1.67k | ::SerializeMany(*this, std::forward<Args>(args)...); | 55 | 1.67k | } |
|
56 | | void write(std::span<const std::byte> src) |
57 | 6.65M | { |
58 | 6.65M | assert(nPos <= vchData.size()); |
59 | 6.65M | size_t nOverwrite = std::min(src.size(), vchData.size() - nPos); |
60 | 6.65M | if (nOverwrite) { |
61 | 19 | memcpy(vchData.data() + nPos, src.data(), nOverwrite); |
62 | 19 | } |
63 | 6.65M | if (nOverwrite < src.size()) { |
64 | 6.65M | vchData.insert(vchData.end(), UCharCast(src.data()) + nOverwrite, UCharCast(src.data() + src.size())); |
65 | 6.65M | } |
66 | 6.65M | nPos += src.size(); |
67 | 6.65M | } |
68 | | template <typename T> |
69 | | VectorWriter& operator<<(const T& obj) |
70 | 372k | { |
71 | 372k | ::Serialize(*this, obj); |
72 | 372k | return (*this); |
73 | 372k | } cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned long>> const&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned long>> const&> const&) Line | Count | Source | 70 | 227 | { | 71 | 227 | ::Serialize(*this, obj); | 72 | 227 | return (*this); | 73 | 227 | } |
VectorWriter& VectorWriter::operator<<<Wrapper<VarIntFormatter<(VarIntMode)1>, int const&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, int const&> const&) Line | Count | Source | 70 | 25.0k | { | 71 | 25.0k | ::Serialize(*this, obj); | 72 | 25.0k | return (*this); | 73 | 25.0k | } |
VectorWriter& VectorWriter::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&) Line | Count | Source | 70 | 124k | { | 71 | 124k | ::Serialize(*this, obj); | 72 | 124k | return (*this); | 73 | 124k | } |
VectorWriter& VectorWriter::operator<<<unsigned char>(unsigned char const&) Line | Count | Source | 70 | 26.3k | { | 71 | 26.3k | ::Serialize(*this, obj); | 72 | 26.3k | return (*this); | 73 | 26.3k | } |
cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned int, 2u>> const&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned int, 2u>> const&> const&) Line | Count | Source | 70 | 227 | { | 71 | 227 | ::Serialize(*this, obj); | 72 | 227 | return (*this); | 73 | 227 | } |
cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 8u>> const&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 8u>> const&> const&) Line | Count | Source | 70 | 227 | { | 71 | 227 | ::Serialize(*this, obj); | 72 | 227 | return (*this); | 73 | 227 | } |
cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>> const&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>> const&> const&) Line | Count | Source | 70 | 132 | { | 71 | 132 | ::Serialize(*this, obj); | 72 | 132 | return (*this); | 73 | 132 | } |
cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 4u>> const&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 4u>> const&> const&) Line | Count | Source | 70 | 125 | { | 71 | 125 | ::Serialize(*this, obj); | 72 | 125 | return (*this); | 73 | 125 | } |
cluster_linearize_tests.cpp:VectorWriter& VectorWriter::operator<<<Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>>&> const&) Line | Count | Source | 70 | 7 | { | 71 | 7 | ::Serialize(*this, obj); | 72 | 7 | return (*this); | 73 | 7 | } |
VectorWriter& VectorWriter::operator<<<std::set<uint256, std::less<uint256>, std::allocator<uint256>>>(std::set<uint256, std::less<uint256>, std::allocator<uint256>> const&) Line | Count | Source | 70 | 3.78k | { | 71 | 3.78k | ::Serialize(*this, obj); | 72 | 3.78k | return (*this); | 73 | 3.78k | } |
VectorWriter& VectorWriter::operator<<<std::span<unsigned char const, 32ul>>(std::span<unsigned char const, 32ul> const&) Line | Count | Source | 70 | 178k | { | 71 | 178k | ::Serialize(*this, obj); | 72 | 178k | return (*this); | 73 | 178k | } |
VectorWriter& VectorWriter::operator<<<unsigned char [4]>(unsigned char const (&) [4]) Line | Count | Source | 70 | 3.78k | { | 71 | 3.78k | ::Serialize(*this, obj); | 72 | 3.78k | return (*this); | 73 | 3.78k | } |
VectorWriter& VectorWriter::operator<<<unsigned int>(unsigned int const&) Line | Count | Source | 70 | 7.08k | { | 71 | 7.08k | ::Serialize(*this, obj); | 72 | 7.08k | return (*this); | 73 | 7.08k | } |
VectorWriter& VectorWriter::operator<<<std::span<unsigned char const, 18446744073709551615ul>>(std::span<unsigned char const, 18446744073709551615ul> const&) Line | Count | Source | 70 | 1.46k | { | 71 | 1.46k | ::Serialize(*this, obj); | 72 | 1.46k | return (*this); | 73 | 1.46k | } |
VectorWriter& VectorWriter::operator<<<std::vector<unsigned char, std::allocator<unsigned char>>>(std::vector<unsigned char, std::allocator<unsigned char>> const&) Line | Count | Source | 70 | 706 | { | 71 | 706 | ::Serialize(*this, obj); | 72 | 706 | return (*this); | 73 | 706 | } |
VectorWriter& VectorWriter::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 | 70 | 1 | { | 71 | 1 | ::Serialize(*this, obj); | 72 | 1 | return (*this); | 73 | 1 | } |
VectorWriter& VectorWriter::operator<<<unsigned long>(unsigned long const&) Line | Count | Source | 70 | 1 | { | 71 | 1 | ::Serialize(*this, obj); | 72 | 1 | return (*this); | 73 | 1 | } |
VectorWriter& VectorWriter::operator<<<int>(int const&) Line | Count | Source | 70 | 26 | { | 71 | 26 | ::Serialize(*this, obj); | 72 | 26 | return (*this); | 73 | 26 | } |
VectorWriter& VectorWriter::operator<<<uint256>(uint256 const&) Line | Count | Source | 70 | 57 | { | 71 | 57 | ::Serialize(*this, obj); | 72 | 57 | return (*this); | 73 | 57 | } |
|
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 | 75.0k | explicit SpanReader(std::span<const unsigned char> data) : m_data{std::as_bytes(data)} {} |
92 | 580k | explicit SpanReader(std::span<const std::byte> data) : m_data{data} {} |
93 | | |
94 | | template<typename T> |
95 | | SpanReader& operator>>(T&& obj) |
96 | 1.44M | { |
97 | 1.44M | ::Unserialize(*this, obj); |
98 | 1.44M | return (*this); |
99 | 1.44M | } SpanReader& SpanReader::operator>><unsigned int&>(unsigned int&) Line | Count | Source | 96 | 14.9k | { | 97 | 14.9k | ::Unserialize(*this, obj); | 98 | 14.9k | return (*this); | 99 | 14.9k | } |
SpanReader& SpanReader::operator>><std::vector<CTxIn, std::allocator<CTxIn>>&>(std::vector<CTxIn, std::allocator<CTxIn>>&) Line | Count | Source | 96 | 1 | { | 97 | 1 | ::Unserialize(*this, obj); | 98 | 1 | return (*this); | 99 | 1 | } |
SpanReader& SpanReader::operator>><unsigned char&>(unsigned char&) Line | Count | Source | 96 | 34.9k | { | 97 | 34.9k | ::Unserialize(*this, obj); | 98 | 34.9k | return (*this); | 99 | 34.9k | } |
SpanReader& SpanReader::operator>><std::vector<CTxOut, std::allocator<CTxOut>>&>(std::vector<CTxOut, std::allocator<CTxOut>>&) Line | Count | Source | 96 | 1 | { | 97 | 1 | ::Unserialize(*this, obj); | 98 | 1 | return (*this); | 99 | 1 | } |
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>>>>&) Line | Count | Source | 96 | 19 | { | 97 | 19 | ::Unserialize(*this, obj); | 98 | 19 | return (*this); | 99 | 19 | } |
cluster_linearize_tests.cpp:SpanReader& SpanReader::operator>><Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned long>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned long>>&>&&) Line | Count | Source | 96 | 681 | { | 97 | 681 | ::Unserialize(*this, obj); | 98 | 681 | return (*this); | 99 | 681 | } |
SpanReader& SpanReader::operator>><Wrapper<VarIntFormatter<(VarIntMode)1>, int&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, int&>&&) Line | Count | Source | 96 | 77.9k | { | 97 | 77.9k | ::Unserialize(*this, obj); | 98 | 77.9k | return (*this); | 99 | 77.9k | } |
SpanReader& SpanReader::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>&&) Line | Count | Source | 96 | 458k | { | 97 | 458k | ::Unserialize(*this, obj); | 98 | 458k | return (*this); | 99 | 458k | } |
cluster_linearize_tests.cpp:SpanReader& SpanReader::operator>><Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned int, 2u>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned int, 2u>>&>&&) Line | Count | Source | 96 | 681 | { | 97 | 681 | ::Unserialize(*this, obj); | 98 | 681 | return (*this); | 99 | 681 | } |
cluster_linearize_tests.cpp:SpanReader& SpanReader::operator>><Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 8u>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 8u>>&>&&) Line | Count | Source | 96 | 681 | { | 97 | 681 | ::Unserialize(*this, obj); | 98 | 681 | return (*this); | 99 | 681 | } |
cluster_linearize_tests.cpp:SpanReader& SpanReader::operator>><Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::IntBitSet<unsigned int>>&>&&) Line | Count | Source | 96 | 396 | { | 97 | 396 | ::Unserialize(*this, obj); | 98 | 396 | return (*this); | 99 | 396 | } |
cluster_linearize_tests.cpp:SpanReader& SpanReader::operator>><Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 4u>>&>>(Wrapper<(anonymous namespace)::DepGraphFormatter, cluster_linearize::DepGraph<bitset_detail::MultiIntBitSet<unsigned char, 4u>>&>&&) Line | Count | Source | 96 | 375 | { | 97 | 375 | ::Unserialize(*this, obj); | 98 | 375 | return (*this); | 99 | 375 | } |
SpanReader& SpanReader::operator>><Coin&>(Coin&) Line | Count | Source | 96 | 83.5k | { | 97 | 83.5k | ::Unserialize(*this, obj); | 98 | 83.5k | return (*this); | 99 | 83.5k | } |
SpanReader& SpanReader::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>&&) Line | Count | Source | 96 | 83.5k | { | 97 | 83.5k | ::Unserialize(*this, obj); | 98 | 83.5k | return (*this); | 99 | 83.5k | } |
SpanReader& SpanReader::operator>><std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul>&&) Line | Count | Source | 96 | 83.5k | { | 97 | 83.5k | ::Unserialize(*this, obj); | 98 | 83.5k | return (*this); | 99 | 83.5k | } |
SpanReader& SpanReader::operator>><uint256&>(uint256&) Line | Count | Source | 96 | 6.91k | { | 97 | 6.91k | ::Unserialize(*this, obj); | 98 | 6.91k | return (*this); | 99 | 6.91k | } |
SpanReader& SpanReader::operator>><bool&>(bool&) Line | Count | Source | 96 | 4 | { | 97 | 4 | ::Unserialize(*this, obj); | 98 | 4 | return (*this); | 99 | 4 | } |
SpanReader& SpanReader::operator>><unsigned short&>(unsigned short&) Line | Count | Source | 96 | 2 | { | 97 | 2 | ::Unserialize(*this, obj); | 98 | 2 | return (*this); | 99 | 2 | } |
SpanReader& SpanReader::operator>><dbwrapper_tests::StringContentsSerializer&>(dbwrapper_tests::StringContentsSerializer&) Line | Count | Source | 96 | 150 | { | 97 | 150 | ::Unserialize(*this, obj); | 98 | 150 | return (*this); | 99 | 150 | } |
SpanReader& SpanReader::operator>><ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>>>>(ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>>>&&) Line | Count | Source | 96 | 3 | { | 97 | 3 | ::Unserialize(*this, obj); | 98 | 3 | return (*this); | 99 | 3 | } |
SpanReader& SpanReader::operator>><ParamsWrapper<TransactionSerParams, CMutableTransaction>>(ParamsWrapper<TransactionSerParams, CMutableTransaction>&&) Line | Count | Source | 96 | 33.5k | { | 97 | 33.5k | ::Unserialize(*this, obj); | 98 | 33.5k | return (*this); | 99 | 33.5k | } |
SpanReader& SpanReader::operator>><CTxOut&>(CTxOut&) Line | Count | Source | 96 | 2.92k | { | 97 | 2.92k | ::Unserialize(*this, obj); | 98 | 2.92k | return (*this); | 99 | 2.92k | } |
SpanReader& SpanReader::operator>><ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>>(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>&&) Line | Count | Source | 96 | 500 | { | 97 | 500 | ::Unserialize(*this, obj); | 98 | 500 | return (*this); | 99 | 500 | } |
SpanReader& SpanReader::operator>><signed char&>(signed char&) Line | Count | Source | 96 | 1 | { | 97 | 1 | ::Unserialize(*this, obj); | 98 | 1 | return (*this); | 99 | 1 | } |
SpanReader& SpanReader::operator>><int&>(int&) Line | Count | Source | 96 | 734 | { | 97 | 734 | ::Unserialize(*this, obj); | 98 | 734 | return (*this); | 99 | 734 | } |
SpanReader& SpanReader::operator>><std::vector<unsigned char, std::allocator<unsigned char>>&>(std::vector<unsigned char, std::allocator<unsigned char>>&) Line | Count | Source | 96 | 29.1k | { | 97 | 29.1k | ::Unserialize(*this, obj); | 98 | 29.1k | return (*this); | 99 | 29.1k | } |
SpanReader& SpanReader::operator>><XOnlyPubKey&>(XOnlyPubKey&) Line | Count | Source | 96 | 4.07k | { | 97 | 4.07k | ::Unserialize(*this, obj); | 98 | 4.07k | return (*this); | 99 | 4.07k | } |
SpanReader& SpanReader::operator>><std::span<std::byte, 33ul>>(std::span<std::byte, 33ul>&&) Line | Count | Source | 96 | 6.10k | { | 97 | 6.10k | ::Unserialize(*this, obj); | 98 | 6.10k | return (*this); | 99 | 6.10k | } |
SpanReader& SpanReader::operator>><wallet::WalletDescriptor&>(wallet::WalletDescriptor&) Line | Count | Source | 96 | 1 | { | 97 | 1 | ::Unserialize(*this, obj); | 98 | 1 | return (*this); | 99 | 1 | } |
SpanReader& SpanReader::operator>><Obfuscation&>(Obfuscation&) Line | Count | Source | 96 | 845 | { | 97 | 845 | ::Unserialize(*this, obj); | 98 | 845 | return (*this); | 99 | 845 | } |
SpanReader& SpanReader::operator>><std::vector<std::byte, std::allocator<std::byte>>&>(std::vector<std::byte, std::allocator<std::byte>>&) Line | Count | Source | 96 | 845 | { | 97 | 845 | ::Unserialize(*this, obj); | 98 | 845 | return (*this); | 99 | 845 | } |
SpanReader& SpanReader::operator>><CBlockLocator&>(CBlockLocator&) Line | Count | Source | 96 | 93 | { | 97 | 93 | ::Unserialize(*this, obj); | 98 | 93 | return (*this); | 99 | 93 | } |
SpanReader& SpanReader::operator>><index_util::DBHeightKey&>(index_util::DBHeightKey&) Line | Count | Source | 96 | 3.09k | { | 97 | 3.09k | ::Unserialize(*this, obj); | 98 | 3.09k | return (*this); | 99 | 3.09k | } |
blockfilterindex.cpp:SpanReader& SpanReader::operator>><(anonymous namespace)::DBVal&>((anonymous namespace)::DBVal&) Line | Count | Source | 96 | 29 | { | 97 | 29 | ::Unserialize(*this, obj); | 98 | 29 | return (*this); | 99 | 29 | } |
SpanReader& SpanReader::operator>><FlatFilePos&>(FlatFilePos&) Line | Count | Source | 96 | 26 | { | 97 | 26 | ::Unserialize(*this, obj); | 98 | 26 | return (*this); | 99 | 26 | } |
blockfilterindex.cpp:SpanReader& SpanReader::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&) Line | Count | Source | 96 | 1.01k | { | 97 | 1.01k | ::Unserialize(*this, obj); | 98 | 1.01k | return (*this); | 99 | 1.01k | } |
coinstatsindex.cpp:SpanReader& SpanReader::operator>><(anonymous namespace)::DBVal&>((anonymous namespace)::DBVal&) Line | Count | Source | 96 | 2 | { | 97 | 2 | ::Unserialize(*this, obj); | 98 | 2 | return (*this); | 99 | 2 | } |
SpanReader& SpanReader::operator>><MuHash3072&>(MuHash3072&) Line | Count | Source | 96 | 28 | { | 97 | 28 | ::Unserialize(*this, obj); | 98 | 28 | return (*this); | 99 | 28 | } |
coinstatsindex.cpp:SpanReader& SpanReader::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&) Line | Count | Source | 96 | 218 | { | 97 | 218 | ::Unserialize(*this, obj); | 98 | 218 | return (*this); | 99 | 218 | } |
SpanReader& SpanReader::operator>><CDiskTxPos&>(CDiskTxPos&) Line | Count | Source | 96 | 142 | { | 97 | 142 | ::Unserialize(*this, obj); | 98 | 142 | return (*this); | 99 | 142 | } |
SpanReader& SpanReader::operator>><std::pair<unsigned long, unsigned long>&>(std::pair<unsigned long, unsigned long>&) Line | Count | Source | 96 | 16 | { | 97 | 16 | ::Unserialize(*this, obj); | 98 | 16 | return (*this); | 99 | 16 | } |
SpanReader& SpanReader::operator>><DBKey&>(DBKey&) Line | Count | Source | 96 | 25 | { | 97 | 25 | ::Unserialize(*this, obj); | 98 | 25 | return (*this); | 99 | 25 | } |
SpanReader& SpanReader::operator>><kernel::CBlockFileInfo&>(kernel::CBlockFileInfo&) Line | Count | Source | 96 | 747 | { | 97 | 747 | ::Unserialize(*this, obj); | 98 | 747 | return (*this); | 99 | 747 | } |
SpanReader& SpanReader::operator>><std::pair<unsigned char, uint256>&>(std::pair<unsigned char, uint256>&) Line | Count | Source | 96 | 133k | { | 97 | 133k | ::Unserialize(*this, obj); | 98 | 133k | return (*this); | 99 | 133k | } |
SpanReader& SpanReader::operator>><ParamsWrapper<TransactionSerParams, CBlock>>(ParamsWrapper<TransactionSerParams, CBlock>&&) Line | Count | Source | 96 | 134k | { | 97 | 134k | ::Unserialize(*this, obj); | 98 | 134k | return (*this); | 99 | 134k | } |
SpanReader& SpanReader::operator>><CMerkleBlock&>(CMerkleBlock&) Line | Count | Source | 96 | 19 | { | 97 | 19 | ::Unserialize(*this, obj); | 98 | 19 | return (*this); | 99 | 19 | } |
SpanReader& SpanReader::operator>><CScript&>(CScript&) Line | Count | Source | 96 | 267 | { | 97 | 267 | ::Unserialize(*this, obj); | 98 | 267 | return (*this); | 99 | 267 | } |
Unexecuted instantiation: SpanReader& SpanReader::operator>><std::vector<uint256, std::allocator<uint256>>&>(std::vector<uint256, std::allocator<uint256>>&) txdb.cpp:SpanReader& SpanReader::operator>><(anonymous namespace)::CoinEntry&>((anonymous namespace)::CoinEntry&) Line | Count | Source | 96 | 221k | { | 97 | 221k | ::Unserialize(*this, obj); | 98 | 221k | return (*this); | 99 | 221k | } |
SpanReader& SpanReader::operator>><CBlockHeader&>(CBlockHeader&) Line | Count | Source | 96 | 1.84k | { | 97 | 1.84k | ::Unserialize(*this, obj); | 98 | 1.84k | return (*this); | 99 | 1.84k | } |
SpanReader& SpanReader::operator>><PartiallySignedTransaction&>(PartiallySignedTransaction&) Line | Count | Source | 96 | 1.32k | { | 97 | 1.32k | ::Unserialize(*this, obj); | 98 | 1.32k | return (*this); | 99 | 1.32k | } |
SpanReader& SpanReader::operator>><unsigned char (&) [5]>(unsigned char (&) [5]) Line | Count | Source | 96 | 1.32k | { | 97 | 1.32k | ::Unserialize(*this, obj); | 98 | 1.32k | return (*this); | 99 | 1.32k | } |
SpanReader& SpanReader::operator>><unsigned char (&) [4]>(unsigned char (&) [4]) Line | Count | Source | 96 | 7.43k | { | 97 | 7.43k | ::Unserialize(*this, obj); | 98 | 7.43k | return (*this); | 99 | 7.43k | } |
SpanReader& SpanReader::operator>><PSBTInput&>(PSBTInput&) Line | Count | Source | 96 | 1.60k | { | 97 | 1.60k | ::Unserialize(*this, obj); | 98 | 1.60k | return (*this); | 99 | 1.60k | } |
SpanReader& SpanReader::operator>><std::set<uint256, std::less<uint256>, std::allocator<uint256>>&>(std::set<uint256, std::less<uint256>, std::allocator<uint256>>&) Line | Count | Source | 96 | 6.66k | { | 97 | 6.66k | ::Unserialize(*this, obj); | 98 | 6.66k | return (*this); | 99 | 6.66k | } |
SpanReader& SpanReader::operator>><PSBTOutput&>(PSBTOutput&) Line | Count | Source | 96 | 2.30k | { | 97 | 2.30k | ::Unserialize(*this, obj); | 98 | 2.30k | return (*this); | 99 | 2.30k | } |
|
100 | | |
101 | 28.7k | size_t size() const { return m_data.size(); } |
102 | 84.0k | bool empty() const { return m_data.empty(); } |
103 | | |
104 | | void read(std::span<std::byte> dst) |
105 | 10.1M | { |
106 | 10.1M | if (dst.size() == 0) { |
107 | 1.08k | return; |
108 | 1.08k | } |
109 | | |
110 | | // Read from the beginning of the buffer |
111 | 10.1M | if (dst.size() > m_data.size()) { |
112 | 1.87k | throw std::ios_base::failure("SpanReader::read(): end of data"); |
113 | 1.87k | } |
114 | 10.1M | memcpy(dst.data(), m_data.data(), dst.size()); |
115 | 10.1M | m_data = m_data.subspan(dst.size()); |
116 | 10.1M | } |
117 | | |
118 | | void ignore(size_t n) |
119 | 1 | { |
120 | 1 | if (n > m_data.size()) { |
121 | 1 | throw std::ios_base::failure("SpanReader::ignore(): end of data"); |
122 | 1 | } |
123 | 0 | m_data = m_data.subspan(n); |
124 | 0 | } |
125 | | }; |
126 | | |
127 | | /** Minimal stream for writing to an existing span of bytes. |
128 | | */ |
129 | | class SpanWriter |
130 | | { |
131 | | private: |
132 | | std::span<std::byte> m_dest; |
133 | | |
134 | | public: |
135 | 4 | explicit SpanWriter(std::span<std::byte> dest) : m_dest{dest} {} |
136 | | template <typename... Args> |
137 | 2 | SpanWriter(std::span<std::byte> dest, Args&&... args) : SpanWriter{dest} |
138 | 2 | { |
139 | 2 | ::SerializeMany(*this, std::forward<Args>(args)...); |
140 | 2 | } SpanWriter::SpanWriter<unsigned char&, unsigned char (&) [4], unsigned char&>(std::span<std::byte, 18446744073709551615ul>, unsigned char&, unsigned char (&) [4], unsigned char&) Line | Count | Source | 137 | 1 | SpanWriter(std::span<std::byte> dest, Args&&... args) : SpanWriter{dest} | 138 | 1 | { | 139 | 1 | ::SerializeMany(*this, std::forward<Args>(args)...); | 140 | 1 | } |
SpanWriter::SpanWriter<unsigned char&, unsigned char&>(std::span<std::byte, 18446744073709551615ul>, unsigned char&, unsigned char&) Line | Count | Source | 137 | 1 | SpanWriter(std::span<std::byte> dest, Args&&... args) : SpanWriter{dest} | 138 | 1 | { | 139 | 1 | ::SerializeMany(*this, std::forward<Args>(args)...); | 140 | 1 | } |
|
141 | | |
142 | | void write(std::span<const std::byte> src) |
143 | 9 | { |
144 | 9 | if (src.size() > m_dest.size()) { |
145 | 2 | throw std::ios_base::failure("SpanWriter::write(): exceeded buffer size"); |
146 | 2 | } |
147 | 7 | memcpy(m_dest.data(), src.data(), src.size()); |
148 | 7 | m_dest = m_dest.subspan(src.size()); |
149 | 7 | } |
150 | | |
151 | | template<typename T> |
152 | | SpanWriter& operator<<(const T& obj) |
153 | 4 | { |
154 | 4 | ::Serialize(*this, obj); |
155 | 4 | return *this; |
156 | 4 | } |
157 | | }; |
158 | | |
159 | | /** Double ended buffer combining vector and stream-like interfaces. |
160 | | * |
161 | | * >> and << read and write unformatted data using the above serialization templates. |
162 | | * Fills with data in linear time; some stringstream implementations take N^2 time. |
163 | | */ |
164 | | class DataStream |
165 | | { |
166 | | protected: |
167 | | using vector_type = SerializeData; |
168 | | vector_type vch; |
169 | | vector_type::size_type m_read_pos{0}; |
170 | | |
171 | | public: |
172 | | typedef vector_type::allocator_type allocator_type; |
173 | | typedef vector_type::size_type size_type; |
174 | | typedef vector_type::difference_type difference_type; |
175 | | typedef vector_type::reference reference; |
176 | | typedef vector_type::const_reference const_reference; |
177 | | typedef vector_type::value_type value_type; |
178 | | typedef vector_type::iterator iterator; |
179 | | typedef vector_type::const_iterator const_iterator; |
180 | | typedef vector_type::reverse_iterator reverse_iterator; |
181 | | |
182 | 8.03M | explicit DataStream() = default; |
183 | 214 | explicit DataStream(std::span<const uint8_t> sp) : DataStream{std::as_bytes(sp)} {} |
184 | 357k | explicit DataStream(std::span<const value_type> sp) : vch(sp.data(), sp.data() + sp.size()) {} |
185 | | |
186 | | std::string str() const |
187 | 758 | { |
188 | 758 | return std::string{UCharCast(data()), UCharCast(data() + size())}; |
189 | 758 | } |
190 | | |
191 | | // |
192 | | // Vector subset |
193 | | // |
194 | 0 | const_iterator begin() const { return vch.begin() + m_read_pos; } |
195 | 190k | iterator begin() { return vch.begin() + m_read_pos; } |
196 | 0 | const_iterator end() const { return vch.end(); } |
197 | 96.6k | iterator end() { return vch.end(); } |
198 | 19.1M | size_type size() const { return vch.size() - m_read_pos; } |
199 | 20.2k | bool empty() const { return vch.size() == m_read_pos; } |
200 | 314k | void resize(size_type n, value_type c = value_type{}) { vch.resize(n + m_read_pos, c); } |
201 | 8.14M | void reserve(size_type n) { vch.reserve(n + m_read_pos); } |
202 | 0 | const_reference operator[](size_type pos) const { return vch[pos + m_read_pos]; } |
203 | 18.1M | reference operator[](size_type pos) { return vch[pos + m_read_pos]; } |
204 | 1.96M | void clear() { vch.clear(); m_read_pos = 0; } |
205 | 8.95M | value_type* data() { return vch.data() + m_read_pos; } |
206 | 7.49k | const value_type* data() const { return vch.data() + m_read_pos; } |
207 | | |
208 | | // |
209 | | // Stream subset |
210 | | // |
211 | | void read(std::span<value_type> dst) |
212 | 12.3M | { |
213 | 12.3M | if (dst.size() == 0) return; |
214 | | |
215 | | // Read from the beginning of the buffer |
216 | 12.3M | auto next_read_pos{CheckedAdd(m_read_pos, dst.size())}; |
217 | 12.3M | if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) { |
218 | 2.21k | throw std::ios_base::failure("DataStream::read(): end of data"); |
219 | 2.21k | } |
220 | 12.3M | memcpy(dst.data(), &vch[m_read_pos], dst.size()); |
221 | 12.3M | if (next_read_pos.value() == vch.size()) { |
222 | | // If fully consumed, reset to empty state. |
223 | 718k | clear(); |
224 | 718k | return; |
225 | 718k | } |
226 | 11.5M | m_read_pos = next_read_pos.value(); |
227 | 11.5M | } |
228 | | |
229 | | void ignore(size_t num_ignore) |
230 | 3.07k | { |
231 | | // Ignore from the beginning of the buffer |
232 | 3.07k | auto next_read_pos{CheckedAdd(m_read_pos, num_ignore)}; |
233 | 3.07k | if (!next_read_pos.has_value() || next_read_pos.value() > vch.size()) { |
234 | 0 | throw std::ios_base::failure("DataStream::ignore(): end of data"); |
235 | 0 | } |
236 | 3.07k | if (next_read_pos.value() == vch.size()) { |
237 | | // If all bytes are ignored, reset to empty state. |
238 | 3 | clear(); |
239 | 3 | return; |
240 | 3 | } |
241 | 3.07k | m_read_pos = next_read_pos.value(); |
242 | 3.07k | } |
243 | | |
244 | | void write(std::span<const value_type> src) |
245 | 46.5M | { |
246 | | // Write to the end of the buffer |
247 | 46.5M | vch.insert(vch.end(), src.begin(), src.end()); |
248 | 46.5M | } |
249 | | |
250 | | template<typename T> |
251 | | DataStream& operator<<(const T& obj) |
252 | 18.1M | { |
253 | 18.1M | ::Serialize(*this, obj); |
254 | 18.1M | return (*this); |
255 | 18.1M | } DataStream& DataStream::operator<<<std::array<unsigned char, 4ul>>(std::array<unsigned char, 4ul> const&) Line | Count | Source | 252 | 4 | { | 253 | 4 | ::Serialize(*this, obj); | 254 | 4 | return (*this); | 255 | 4 | } |
DataStream& DataStream::operator<<<unsigned char>(unsigned char const&) Line | Count | Source | 252 | 46.3k | { | 253 | 46.3k | ::Serialize(*this, obj); | 254 | 46.3k | return (*this); | 255 | 46.3k | } |
DataStream& DataStream::operator<<<uint256>(uint256 const&) Line | Count | Source | 252 | 31.0k | { | 253 | 31.0k | ::Serialize(*this, obj); | 254 | 31.0k | return (*this); | 255 | 31.0k | } |
DataStream& DataStream::operator<<<std::span<unsigned char const, 32ul>>(std::span<unsigned char const, 32ul> const&) Line | Count | Source | 252 | 8.11M | { | 253 | 8.11M | ::Serialize(*this, obj); | 254 | 8.11M | return (*this); | 255 | 8.11M | } |
DataStream& DataStream::operator<<<int>(int const&) Line | Count | Source | 252 | 27.3k | { | 253 | 27.3k | ::Serialize(*this, obj); | 254 | 27.3k | return (*this); | 255 | 27.3k | } |
DataStream& DataStream::operator<<<ParamsWrapper<CAddress::SerParams, AddrInfo>>(ParamsWrapper<CAddress::SerParams, AddrInfo> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<AddrMan>(AddrMan const&) Line | Count | Source | 252 | 7 | { | 253 | 7 | ::Serialize(*this, obj); | 254 | 7 | return (*this); | 255 | 7 | } |
DataStream& DataStream::operator<<<CBlockHeaderAndShortTxIDs>(CBlockHeaderAndShortTxIDs const&) Line | Count | Source | 252 | 4 | { | 253 | 4 | ::Serialize(*this, obj); | 254 | 4 | return (*this); | 255 | 4 | } |
DataStream& DataStream::operator<<<blockencodings_tests::TestHeaderAndShortIDs>(blockencodings_tests::TestHeaderAndShortIDs const&) Line | Count | Source | 252 | 5 | { | 253 | 5 | ::Serialize(*this, obj); | 254 | 5 | return (*this); | 255 | 5 | } |
DataStream& DataStream::operator<<<BlockTransactionsRequest>(BlockTransactionsRequest const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<BlockFilter>(BlockFilter const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::vector<unsigned char, std::allocator<unsigned char>>>(std::vector<unsigned char, std::allocator<unsigned char>> const&) Line | Count | Source | 252 | 73.1k | { | 253 | 73.1k | ::Serialize(*this, obj); | 254 | 73.1k | return (*this); | 255 | 73.1k | } |
DataStream& DataStream::operator<<<CBloomFilter>(CBloomFilter const&) Line | Count | Source | 252 | 3 | { | 253 | 3 | ::Serialize(*this, obj); | 254 | 3 | return (*this); | 255 | 3 | } |
DataStream& DataStream::operator<<<CMerkleBlock>(CMerkleBlock const&) Line | Count | Source | 252 | 13 | { | 253 | 13 | ::Serialize(*this, obj); | 254 | 13 | return (*this); | 255 | 13 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&) Line | Count | Source | 252 | 272k | { | 253 | 272k | ::Serialize(*this, obj); | 254 | 272k | return (*this); | 255 | 272k | } |
DataStream& DataStream::operator<<<MuHash3072>(MuHash3072 const&) Line | Count | Source | 252 | 124 | { | 253 | 124 | ::Serialize(*this, obj); | 254 | 124 | return (*this); | 255 | 124 | } |
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 | 252 | 121k | { | 253 | 121k | ::Serialize(*this, obj); | 254 | 121k | return (*this); | 255 | 121k | } |
DataStream& DataStream::operator<<<unsigned int>(unsigned int const&) Line | Count | Source | 252 | 55.6k | { | 253 | 55.6k | ::Serialize(*this, obj); | 254 | 55.6k | return (*this); | 255 | 55.6k | } |
DataStream& DataStream::operator<<<bool>(bool const&) Line | Count | Source | 252 | 46.5k | { | 253 | 46.5k | ::Serialize(*this, obj); | 254 | 46.5k | return (*this); | 255 | 46.5k | } |
DataStream& DataStream::operator<<<dbwrapper_tests::StringContentsSerializer>(dbwrapper_tests::StringContentsSerializer const&) Line | Count | Source | 252 | 102 | { | 253 | 102 | ::Serialize(*this, obj); | 254 | 102 | return (*this); | 255 | 102 | } |
DataStream& DataStream::operator<<<CPubKey>(CPubKey const&) Line | Count | Source | 252 | 12 | { | 253 | 12 | ::Serialize(*this, obj); | 254 | 12 | return (*this); | 255 | 12 | } |
DataStream& DataStream::operator<<<std::span<unsigned char const, 18446744073709551615ul>>(std::span<unsigned char const, 18446744073709551615ul> const&) Line | Count | Source | 252 | 183k | { | 253 | 183k | ::Serialize(*this, obj); | 254 | 183k | return (*this); | 255 | 183k | } |
DataStream& DataStream::operator<<<CMessageHeader>(CMessageHeader const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<ParamsWrapper<CAddress::SerParams, CNetAddr>>(ParamsWrapper<CAddress::SerParams, CNetAddr> const&) Line | Count | Source | 252 | 10 | { | 253 | 10 | ::Serialize(*this, obj); | 254 | 10 | return (*this); | 255 | 10 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 6ul>>(std::array<std::byte, 6ul> const&) Line | Count | Source | 252 | 3 | { | 253 | 3 | ::Serialize(*this, obj); | 254 | 3 | return (*this); | 255 | 3 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 4ul>>(std::array<std::byte, 4ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 8ul>>(std::array<std::byte, 8ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 18ul>>(std::array<std::byte, 18ul> const&) Line | Count | Source | 252 | 6 | { | 253 | 6 | ::Serialize(*this, obj); | 254 | 6 | return (*this); | 255 | 6 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 3ul>>(std::array<std::byte, 3ul> const&) Line | Count | Source | 252 | 4 | { | 253 | 4 | ::Serialize(*this, obj); | 254 | 4 | return (*this); | 255 | 4 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 12ul>>(std::array<std::byte, 12ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 34ul>>(std::array<std::byte, 34ul> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 13ul>>(std::array<std::byte, 13ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::array<std::byte, 2ul>>(std::array<std::byte, 2ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>> const>>(ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>> const> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<CPartialMerkleTree>(CPartialMerkleTree const&) Line | Count | Source | 252 | 168 | { | 253 | 168 | ::Serialize(*this, obj); | 254 | 168 | return (*this); | 255 | 168 | } |
DataStream& DataStream::operator<<<std::vector<int, std::allocator<int>>>(std::vector<int, std::allocator<int>> const&) Line | Count | Source | 252 | 269k | { | 253 | 269k | ::Serialize(*this, obj); | 254 | 269k | return (*this); | 255 | 269k | } |
DataStream& DataStream::operator<<<prevector<8u, int, unsigned int, int>>(prevector<8u, int, unsigned int, int> const&) Line | Count | Source | 252 | 269k | { | 253 | 269k | ::Serialize(*this, obj); | 254 | 269k | return (*this); | 255 | 269k | } |
DataStream& DataStream::operator<<<unsigned long>(unsigned long const&) Line | Count | Source | 252 | 99.3k | { | 253 | 99.3k | ::Serialize(*this, obj); | 254 | 99.3k | return (*this); | 255 | 99.3k | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)1>, int&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, int&> const&) Line | Count | Source | 252 | 100k | { | 253 | 100k | ::Serialize(*this, obj); | 254 | 100k | return (*this); | 255 | 100k | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)1>, signed char&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, signed char&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned char&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned char&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)1>, short&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, short&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned short&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned short&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&) Line | Count | Source | 252 | 178k | { | 253 | 178k | ::Serialize(*this, obj); | 254 | 178k | return (*this); | 255 | 178k | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)1>, long long&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, long long&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long long&> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::array<unsigned char, 32ul>>(std::array<unsigned char, 32ul> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<std::span<char const, 18446744073709551615ul>>(std::span<char const, 18446744073709551615ul> const&) Line | Count | Source | 252 | 8 | { | 253 | 8 | ::Serialize(*this, obj); | 254 | 8 | return (*this); | 255 | 8 | } |
DataStream& DataStream::operator<<<serialize_tests::CSerializeMethodsTestSingle>(serialize_tests::CSerializeMethodsTestSingle const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<serialize_tests::CSerializeMethodsTestMany>(serialize_tests::CSerializeMethodsTestMany const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<unsigned char [16]>(unsigned char const (&) [16]) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<ParamsWrapper<TransactionSerParams, CMutableTransaction>>(ParamsWrapper<TransactionSerParams, CMutableTransaction> const&) Line | Count | Source | 252 | 287 | { | 253 | 287 | ::Serialize(*this, obj); | 254 | 287 | return (*this); | 255 | 287 | } |
DataStream& DataStream::operator<<<std::byte>(std::byte const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<ParamsWrapper<serialize_tests::BaseFormat, serialize_tests::Base>>(ParamsWrapper<serialize_tests::BaseFormat, serialize_tests::Base> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<ParamsWrapper<serialize_tests::BaseFormat, std::vector<serialize_tests::Base, std::allocator<serialize_tests::Base>>>>(ParamsWrapper<serialize_tests::BaseFormat, std::vector<serialize_tests::Base, std::allocator<serialize_tests::Base>>> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<ParamsWrapper<serialize_tests::DerivedAndBaseFormat, serialize_tests::Derived>>(ParamsWrapper<serialize_tests::DerivedAndBaseFormat, serialize_tests::Derived> const&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
DataStream& DataStream::operator<<<std::vector<std::byte, std::allocator<std::byte>>>(std::vector<std::byte, std::allocator<std::byte>> const&) Line | Count | Source | 252 | 502 | { | 253 | 502 | ::Serialize(*this, obj); | 254 | 502 | return (*this); | 255 | 502 | } |
DataStream& DataStream::operator<<<Obfuscation>(Obfuscation const&) Line | Count | Source | 252 | 501 | { | 253 | 501 | ::Serialize(*this, obj); | 254 | 501 | return (*this); | 255 | 501 | } |
DataStream& DataStream::operator<<<uint160>(uint160 const&) Line | Count | Source | 252 | 3 | { | 253 | 3 | ::Serialize(*this, obj); | 254 | 3 | return (*this); | 255 | 3 | } |
DataStream& DataStream::operator<<<std::span<unsigned char const, 20ul>>(std::span<unsigned char const, 20ul> const&) Line | Count | Source | 252 | 3 | { | 253 | 3 | ::Serialize(*this, obj); | 254 | 3 | return (*this); | 255 | 3 | } |
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&) Line | Count | Source | 252 | 147 | { | 253 | 147 | ::Serialize(*this, obj); | 254 | 147 | return (*this); | 255 | 147 | } |
DataStream& DataStream::operator<<<std::span<std::byte const, 18446744073709551615ul>>(std::span<std::byte const, 18446744073709551615ul> const&) Line | Count | Source | 252 | 2.39k | { | 253 | 2.39k | ::Serialize(*this, obj); | 254 | 2.39k | return (*this); | 255 | 2.39k | } |
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&) Line | Count | Source | 252 | 56.2k | { | 253 | 56.2k | ::Serialize(*this, obj); | 254 | 56.2k | return (*this); | 255 | 56.2k | } |
DataStream& DataStream::operator<<<PartiallySignedTransaction>(PartiallySignedTransaction const&) Line | Count | Source | 252 | 864 | { | 253 | 864 | ::Serialize(*this, obj); | 254 | 864 | return (*this); | 255 | 864 | } |
DataStream& DataStream::operator<<<unsigned char [5]>(unsigned char const (&) [5]) Line | Count | Source | 252 | 864 | { | 253 | 864 | ::Serialize(*this, obj); | 254 | 864 | return (*this); | 255 | 864 | } |
DataStream& DataStream::operator<<<unsigned char [4]>(unsigned char const (&) [4]) Line | Count | Source | 252 | 738 | { | 253 | 738 | ::Serialize(*this, obj); | 254 | 738 | return (*this); | 255 | 738 | } |
DataStream& DataStream::operator<<<PSBTInput>(PSBTInput const&) Line | Count | Source | 252 | 1.25k | { | 253 | 1.25k | ::Serialize(*this, obj); | 254 | 1.25k | return (*this); | 255 | 1.25k | } |
DataStream& DataStream::operator<<<CScript>(CScript const&) Line | Count | Source | 252 | 214 | { | 253 | 214 | ::Serialize(*this, obj); | 254 | 214 | return (*this); | 255 | 214 | } |
DataStream& DataStream::operator<<<PSBTOutput>(PSBTOutput const&) Line | Count | Source | 252 | 1.88k | { | 253 | 1.88k | ::Serialize(*this, obj); | 254 | 1.88k | return (*this); | 255 | 1.88k | } |
DataStream& DataStream::operator<<<CBlockHeader>(CBlockHeader const&) Line | Count | Source | 252 | 94.3k | { | 253 | 94.3k | ::Serialize(*this, obj); | 254 | 94.3k | return (*this); | 255 | 94.3k | } |
DataStream& DataStream::operator<<<CBlockLocator>(CBlockLocator const&) Line | Count | Source | 252 | 27.4k | { | 253 | 27.4k | ::Serialize(*this, obj); | 254 | 27.4k | return (*this); | 255 | 27.4k | } |
DataStream& DataStream::operator<<<index_util::DBHeightKey>(index_util::DBHeightKey const&) Line | Count | Source | 252 | 13.5k | { | 253 | 13.5k | ::Serialize(*this, obj); | 254 | 13.5k | return (*this); | 255 | 13.5k | } |
DataStream& DataStream::operator<<<index_util::DBHashKey>(index_util::DBHashKey const&) Line | Count | Source | 252 | 263 | { | 253 | 263 | ::Serialize(*this, obj); | 254 | 263 | return (*this); | 255 | 263 | } |
DataStream& DataStream::operator<<<FlatFilePos>(FlatFilePos const&) Line | Count | Source | 252 | 184 | { | 253 | 184 | ::Serialize(*this, obj); | 254 | 184 | return (*this); | 255 | 184 | } |
blockfilterindex.cpp:DataStream& DataStream::operator<<<std::pair<uint256, (anonymous namespace)::DBVal>>(std::pair<uint256, (anonymous namespace)::DBVal> const&) Line | Count | Source | 252 | 7.54k | { | 253 | 7.54k | ::Serialize(*this, obj); | 254 | 7.54k | return (*this); | 255 | 7.54k | } |
blockfilterindex.cpp:DataStream& DataStream::operator<<<(anonymous namespace)::DBVal>((anonymous namespace)::DBVal const&) Line | Count | Source | 252 | 111 | { | 253 | 111 | ::Serialize(*this, obj); | 254 | 111 | return (*this); | 255 | 111 | } |
coinstatsindex.cpp:DataStream& DataStream::operator<<<std::pair<uint256, (anonymous namespace)::DBVal>>(std::pair<uint256, (anonymous namespace)::DBVal> const&) Line | Count | Source | 252 | 3.86k | { | 253 | 3.86k | ::Serialize(*this, obj); | 254 | 3.86k | return (*this); | 255 | 3.86k | } |
coinstatsindex.cpp:DataStream& DataStream::operator<<<(anonymous namespace)::DBVal>((anonymous namespace)::DBVal const&) Line | Count | Source | 252 | 121 | { | 253 | 121 | ::Serialize(*this, obj); | 254 | 121 | return (*this); | 255 | 121 | } |
DataStream& DataStream::operator<<<std::pair<unsigned char, uint256>>(std::pair<unsigned char, uint256> const&) Line | Count | Source | 252 | 125k | { | 253 | 125k | ::Serialize(*this, obj); | 254 | 125k | return (*this); | 255 | 125k | } |
DataStream& DataStream::operator<<<CDiskTxPos>(CDiskTxPos const&) Line | Count | Source | 252 | 3.74k | { | 253 | 3.74k | ::Serialize(*this, obj); | 254 | 3.74k | return (*this); | 255 | 3.74k | } |
DataStream& DataStream::operator<<<char [12]>(char const (&) [12]) Line | Count | Source | 252 | 28 | { | 253 | 28 | ::Serialize(*this, obj); | 254 | 28 | return (*this); | 255 | 28 | } |
DataStream& DataStream::operator<<<std::pair<unsigned long, unsigned long>>(std::pair<unsigned long, unsigned long> const&) Line | Count | Source | 252 | 6 | { | 253 | 6 | ::Serialize(*this, obj); | 254 | 6 | return (*this); | 255 | 6 | } |
DataStream& DataStream::operator<<<DBKey>(DBKey const&) Line | Count | Source | 252 | 44 | { | 253 | 44 | ::Serialize(*this, obj); | 254 | 44 | return (*this); | 255 | 44 | } |
DataStream& DataStream::operator<<<char [1]>(char const (&) [1]) Line | Count | Source | 252 | 38 | { | 253 | 38 | ::Serialize(*this, obj); | 254 | 38 | return (*this); | 255 | 38 | } |
DataStream& DataStream::operator<<<std::pair<unsigned char, unsigned long>>(std::pair<unsigned char, unsigned long> const&) Line | Count | Source | 252 | 35 | { | 253 | 35 | ::Serialize(*this, obj); | 254 | 35 | return (*this); | 255 | 35 | } |
DataStream& DataStream::operator<<<COutPoint>(COutPoint const&) Line | Count | Source | 252 | 5.97k | { | 253 | 5.97k | ::Serialize(*this, obj); | 254 | 5.97k | return (*this); | 255 | 5.97k | } |
DataStream& DataStream::operator<<<CTxOut>(CTxOut const&) Line | Count | Source | 252 | 5.86k | { | 253 | 5.86k | ::Serialize(*this, obj); | 254 | 5.86k | return (*this); | 255 | 5.86k | } |
DataStream& DataStream::operator<<<std::pair<unsigned char, int>>(std::pair<unsigned char, int> const&) Line | Count | Source | 252 | 3.96k | { | 253 | 3.96k | ::Serialize(*this, obj); | 254 | 3.96k | return (*this); | 255 | 3.96k | } |
DataStream& DataStream::operator<<<kernel::CBlockFileInfo>(kernel::CBlockFileInfo const&) Line | Count | Source | 252 | 1.61k | { | 253 | 1.61k | ::Serialize(*this, obj); | 254 | 1.61k | return (*this); | 255 | 1.61k | } |
DataStream& DataStream::operator<<<CDiskBlockIndex>(CDiskBlockIndex const&) Line | Count | Source | 252 | 118k | { | 253 | 118k | ::Serialize(*this, obj); | 254 | 118k | return (*this); | 255 | 118k | } |
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 | 252 | 1.17k | { | 253 | 1.17k | ::Serialize(*this, obj); | 254 | 1.17k | return (*this); | 255 | 1.17k | } |
DataStream& DataStream::operator<<<ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> const>>(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const> const> const&) Line | Count | Source | 252 | 23.2k | { | 253 | 23.2k | ::Serialize(*this, obj); | 254 | 23.2k | return (*this); | 255 | 23.2k | } |
DataStream& DataStream::operator<<<std::vector<CCoin, std::allocator<CCoin>>>(std::vector<CCoin, std::allocator<CCoin>> const&) Line | Count | Source | 252 | 1 | { | 253 | 1 | ::Serialize(*this, obj); | 254 | 1 | return (*this); | 255 | 1 | } |
DataStream& DataStream::operator<<<ParamsWrapper<TransactionSerParams, CBlock const>>(ParamsWrapper<TransactionSerParams, CBlock const> const&) Line | Count | Source | 252 | 5 | { | 253 | 5 | ::Serialize(*this, obj); | 254 | 5 | return (*this); | 255 | 5 | } |
txdb.cpp:DataStream& DataStream::operator<<<(anonymous namespace)::CoinEntry>((anonymous namespace)::CoinEntry const&) Line | Count | Source | 252 | 7.02M | { | 253 | 7.02M | ::Serialize(*this, obj); | 254 | 7.02M | return (*this); | 255 | 7.02M | } |
DataStream& DataStream::operator<<<std::vector<uint256, std::allocator<uint256>>>(std::vector<uint256, std::allocator<uint256>> const&) Line | Count | Source | 252 | 3.67k | { | 253 | 3.67k | ::Serialize(*this, obj); | 254 | 3.67k | return (*this); | 255 | 3.67k | } |
DataStream& DataStream::operator<<<Coin>(Coin const&) Line | Count | Source | 252 | 272k | { | 253 | 272k | ::Serialize(*this, obj); | 254 | 272k | return (*this); | 255 | 272k | } |
DataStream& DataStream::operator<<<std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul> const&) Line | Count | Source | 252 | 94.6k | { | 253 | 94.6k | ::Serialize(*this, obj); | 254 | 94.6k | return (*this); | 255 | 94.6k | } |
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&) Line | Count | Source | 252 | 23.2k | { | 253 | 23.2k | ::Serialize(*this, obj); | 254 | 23.2k | return (*this); | 255 | 23.2k | } |
DataStream& DataStream::operator<<<wallet::CWalletTx>(wallet::CWalletTx const&) Line | Count | Source | 252 | 23.2k | { | 253 | 23.2k | ::Serialize(*this, obj); | 254 | 23.2k | return (*this); | 255 | 23.2k | } |
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&) Line | Count | Source | 252 | 23.2k | { | 253 | 23.2k | ::Serialize(*this, obj); | 254 | 23.2k | return (*this); | 255 | 23.2k | } |
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&) Line | Count | Source | 252 | 23.2k | { | 253 | 23.2k | ::Serialize(*this, obj); | 254 | 23.2k | return (*this); | 255 | 23.2k | } |
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 | 252 | 102k | { | 253 | 102k | ::Serialize(*this, obj); | 254 | 102k | return (*this); | 255 | 102k | } |
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&) 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 | 252 | 4.24k | { | 253 | 4.24k | ::Serialize(*this, obj); | 254 | 4.24k | return (*this); | 255 | 4.24k | } |
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&) DataStream& DataStream::operator<<<wallet::CMasterKey>(wallet::CMasterKey const&) Line | Count | Source | 252 | 26 | { | 253 | 26 | ::Serialize(*this, obj); | 254 | 26 | return (*this); | 255 | 26 | } |
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&) DataStream& DataStream::operator<<<long>(long const&) Line | Count | Source | 252 | 17.6k | { | 253 | 17.6k | ::Serialize(*this, obj); | 254 | 17.6k | return (*this); | 255 | 17.6k | } |
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 | 252 | 4.03k | { | 253 | 4.03k | ::Serialize(*this, obj); | 254 | 4.03k | return (*this); | 255 | 4.03k | } |
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 | 252 | 4.77k | { | 253 | 4.77k | ::Serialize(*this, obj); | 254 | 4.77k | return (*this); | 255 | 4.77k | } |
DataStream& DataStream::operator<<<wallet::WalletDescriptor>(wallet::WalletDescriptor const&) Line | Count | Source | 252 | 102k | { | 253 | 102k | ::Serialize(*this, obj); | 254 | 102k | return (*this); | 255 | 102k | } |
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&) Line | Count | Source | 252 | 10.0k | { | 253 | 10.0k | ::Serialize(*this, obj); | 254 | 10.0k | return (*this); | 255 | 10.0k | } |
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 | 252 | 8.88k | { | 253 | 8.88k | ::Serialize(*this, obj); | 254 | 8.88k | return (*this); | 255 | 8.88k | } |
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&) Line | Count | Source | 252 | 2 | { | 253 | 2 | ::Serialize(*this, obj); | 254 | 2 | return (*this); | 255 | 2 | } |
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&) Line | Count | Source | 252 | 29 | { | 253 | 29 | ::Serialize(*this, obj); | 254 | 29 | return (*this); | 255 | 29 | } |
DataStream& DataStream::operator<<<ParamsWrapper<TransactionSerParams, CTransaction const>>(ParamsWrapper<TransactionSerParams, CTransaction const> const&) Line | Count | Source | 252 | 5.44k | { | 253 | 5.44k | ::Serialize(*this, obj); | 254 | 5.44k | return (*this); | 255 | 5.44k | } |
|
256 | | |
257 | | template <typename T> |
258 | | DataStream& operator>>(T&& obj) |
259 | 2.17M | { |
260 | 2.17M | ::Unserialize(*this, obj); |
261 | 2.17M | return (*this); |
262 | 2.17M | } DataStream& DataStream::operator>><AddrMan&>(AddrMan&) Line | Count | Source | 259 | 7 | { | 260 | 7 | ::Unserialize(*this, obj); | 261 | 7 | return (*this); | 262 | 7 | } |
DataStream& DataStream::operator>><unsigned char (&) [4]>(unsigned char (&) [4]) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><blockencodings_tests::TestHeaderAndShortIDs&>(blockencodings_tests::TestHeaderAndShortIDs&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><CBlockHeaderAndShortTxIDs&>(CBlockHeaderAndShortTxIDs&) Line | Count | Source | 259 | 20.1k | { | 260 | 20.1k | ::Unserialize(*this, obj); | 261 | 20.1k | return (*this); | 262 | 20.1k | } |
DataStream& DataStream::operator>><BlockTransactionsRequest&>(BlockTransactionsRequest&) Line | Count | Source | 259 | 616 | { | 260 | 616 | ::Unserialize(*this, obj); | 261 | 616 | return (*this); | 262 | 616 | } |
DataStream& DataStream::operator>><BlockFilter&>(BlockFilter&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><unsigned char&>(unsigned char&) Line | Count | Source | 259 | 2.22k | { | 260 | 2.22k | ::Unserialize(*this, obj); | 261 | 2.22k | return (*this); | 262 | 2.22k | } |
DataStream& DataStream::operator>><uint256&>(uint256&) Line | Count | Source | 259 | 24.1k | { | 260 | 24.1k | ::Unserialize(*this, obj); | 261 | 24.1k | return (*this); | 262 | 24.1k | } |
DataStream& DataStream::operator>><std::vector<unsigned char, std::allocator<unsigned char>>&>(std::vector<unsigned char, std::allocator<unsigned char>>&) Line | Count | Source | 259 | 4.79k | { | 260 | 4.79k | ::Unserialize(*this, obj); | 261 | 4.79k | return (*this); | 262 | 4.79k | } |
DataStream& DataStream::operator>><unsigned int&>(unsigned int&) Line | Count | Source | 259 | 23.5k | { | 260 | 23.5k | ::Unserialize(*this, obj); | 261 | 23.5k | return (*this); | 262 | 23.5k | } |
DataStream& DataStream::operator>><std::vector<CTxIn, std::allocator<CTxIn>>&>(std::vector<CTxIn, std::allocator<CTxIn>>&) Line | Count | Source | 259 | 263 | { | 260 | 263 | ::Unserialize(*this, obj); | 261 | 263 | return (*this); | 262 | 263 | } |
DataStream& DataStream::operator>><std::vector<CTxOut, std::allocator<CTxOut>>&>(std::vector<CTxOut, std::allocator<CTxOut>>&) Line | Count | Source | 259 | 219 | { | 260 | 219 | ::Unserialize(*this, obj); | 261 | 219 | return (*this); | 262 | 219 | } |
DataStream& DataStream::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>>>>&) Line | Count | Source | 259 | 4.59k | { | 260 | 4.59k | ::Unserialize(*this, obj); | 261 | 4.59k | return (*this); | 262 | 4.59k | } |
DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, CBlock>>(ParamsWrapper<TransactionSerParams, CBlock>&&) Line | Count | Source | 259 | 37.1k | { | 260 | 37.1k | ::Unserialize(*this, obj); | 261 | 37.1k | return (*this); | 262 | 37.1k | } |
DataStream& DataStream::operator>><MuHash3072&>(MuHash3072&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><CPubKey&>(CPubKey&) Line | Count | Source | 259 | 2.87k | { | 260 | 2.87k | ::Unserialize(*this, obj); | 261 | 2.87k | return (*this); | 262 | 2.87k | } |
DataStream& DataStream::operator>><std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul>&&) Line | Count | Source | 259 | 224k | { | 260 | 224k | ::Unserialize(*this, obj); | 261 | 224k | return (*this); | 262 | 224k | } |
DataStream& DataStream::operator>><ParamsWrapper<CAddress::SerParams, CNetAddr>>(ParamsWrapper<CAddress::SerParams, CNetAddr>&&) Line | Count | Source | 259 | 20 | { | 260 | 20 | ::Unserialize(*this, obj); | 261 | 20 | return (*this); | 262 | 20 | } |
DataStream& DataStream::operator>><CPartialMerkleTreeTester&>(CPartialMerkleTreeTester&) Line | Count | Source | 259 | 168 | { | 260 | 168 | ::Unserialize(*this, obj); | 261 | 168 | return (*this); | 262 | 168 | } |
DataStream& DataStream::operator>><unsigned long&>(unsigned long&) Line | Count | Source | 259 | 14.2k | { | 260 | 14.2k | ::Unserialize(*this, obj); | 261 | 14.2k | return (*this); | 262 | 14.2k | } |
DataStream& DataStream::operator>><Wrapper<VarIntFormatter<(VarIntMode)1>, int&>>(Wrapper<VarIntFormatter<(VarIntMode)1>, int&>&&) Line | Count | Source | 259 | 100k | { | 260 | 100k | ::Unserialize(*this, obj); | 261 | 100k | return (*this); | 262 | 100k | } |
DataStream& DataStream::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>&&) Line | Count | Source | 259 | 221k | { | 260 | 221k | ::Unserialize(*this, obj); | 261 | 221k | return (*this); | 262 | 221k | } |
DataStream& DataStream::operator>><std::array<unsigned char, 32ul>&>(std::array<unsigned char, 32ul>&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><serialize_tests::CSerializeMethodsTestMany&>(serialize_tests::CSerializeMethodsTestMany&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><serialize_tests::CSerializeMethodsTestSingle&>(serialize_tests::CSerializeMethodsTestSingle&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><std::span<std::byte, 2ul>>(std::span<std::byte, 2ul>&&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><std::byte&>(std::byte&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><ParamsWrapper<serialize_tests::BaseFormat, serialize_tests::Base>>(ParamsWrapper<serialize_tests::BaseFormat, serialize_tests::Base>&&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><ParamsWrapper<serialize_tests::BaseFormat, std::vector<serialize_tests::Base, std::allocator<serialize_tests::Base>>>>(ParamsWrapper<serialize_tests::BaseFormat, std::vector<serialize_tests::Base, std::allocator<serialize_tests::Base>>>&&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><Obfuscation&>(Obfuscation&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><std::vector<std::byte, std::allocator<std::byte>>&>(std::vector<std::byte, std::allocator<std::byte>>&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><unsigned short&>(unsigned short&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>>(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>&&) Line | Count | Source | 259 | 24.0k | { | 260 | 24.0k | ::Unserialize(*this, obj); | 261 | 24.0k | return (*this); | 262 | 24.0k | } |
DataStream& DataStream::operator>><ParamsWrapper<TransactionSerParams, CMutableTransaction>>(ParamsWrapper<TransactionSerParams, CMutableTransaction>&&) Line | Count | Source | 259 | 24 | { | 260 | 24 | ::Unserialize(*this, obj); | 261 | 24 | return (*this); | 262 | 24 | } |
DataStream& DataStream::operator>><uint160&>(uint160&) Line | Count | Source | 259 | 91 | { | 260 | 91 | ::Unserialize(*this, obj); | 261 | 91 | return (*this); | 262 | 91 | } |
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>>&) Line | Count | Source | 259 | 33.2k | { | 260 | 33.2k | ::Unserialize(*this, obj); | 261 | 33.2k | return (*this); | 262 | 33.2k | } |
DataStream& DataStream::operator>><PartiallySignedTransaction&>(PartiallySignedTransaction&) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><unsigned char (&) [5]>(unsigned char (&) [5]) Line | Count | Source | 259 | 1 | { | 260 | 1 | ::Unserialize(*this, obj); | 261 | 1 | return (*this); | 262 | 1 | } |
DataStream& DataStream::operator>><PSBTInput&>(PSBTInput&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><CScript&>(CScript&) Line | Count | Source | 259 | 188 | { | 260 | 188 | ::Unserialize(*this, obj); | 261 | 188 | return (*this); | 262 | 188 | } |
Unexecuted instantiation: DataStream& DataStream::operator>><std::set<uint256, std::less<uint256>, std::allocator<uint256>>&>(std::set<uint256, std::less<uint256>, std::allocator<uint256>>&) DataStream& DataStream::operator>><PSBTOutput&>(PSBTOutput&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>>(Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>&&) Line | Count | Source | 259 | 7 | { | 260 | 7 | ::Unserialize(*this, obj); | 261 | 7 | return (*this); | 262 | 7 | } |
blockfilterindex.cpp:DataStream& DataStream::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&) Line | Count | Source | 259 | 2.97k | { | 260 | 2.97k | ::Unserialize(*this, obj); | 261 | 2.97k | return (*this); | 262 | 2.97k | } |
coinstatsindex.cpp:DataStream& DataStream::operator>><std::pair<uint256, (anonymous namespace)::DBVal>&>(std::pair<uint256, (anonymous namespace)::DBVal>&) Line | Count | Source | 259 | 121 | { | 260 | 121 | ::Unserialize(*this, obj); | 261 | 121 | return (*this); | 262 | 121 | } |
DataStream& DataStream::operator>><CMessageHeader&>(CMessageHeader&) Line | Count | Source | 259 | 152k | { | 260 | 152k | ::Unserialize(*this, obj); | 261 | 152k | return (*this); | 262 | 152k | } |
DataStream& DataStream::operator>><int&>(int&) Line | Count | Source | 259 | 11.1k | { | 260 | 11.1k | ::Unserialize(*this, obj); | 261 | 11.1k | return (*this); | 262 | 11.1k | } |
DataStream& DataStream::operator>><Wrapper<CustomUintFormatter<8, false>, ServiceFlags&>>(Wrapper<CustomUintFormatter<8, false>, ServiceFlags&>&&) Line | Count | Source | 259 | 1.54k | { | 260 | 1.54k | ::Unserialize(*this, obj); | 261 | 1.54k | return (*this); | 262 | 1.54k | } |
DataStream& DataStream::operator>><long&>(long&) Line | Count | Source | 259 | 2.70k | { | 260 | 2.70k | ::Unserialize(*this, obj); | 261 | 2.70k | return (*this); | 262 | 2.70k | } |
DataStream& DataStream::operator>><ParamsWrapper<CNetAddr::SerParams, CService>>(ParamsWrapper<CNetAddr::SerParams, CService>&&) Line | Count | Source | 259 | 1.54k | { | 260 | 1.54k | ::Unserialize(*this, obj); | 261 | 1.54k | return (*this); | 262 | 1.54k | } |
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 | 259 | 1.52k | { | 260 | 1.52k | ::Unserialize(*this, obj); | 261 | 1.52k | return (*this); | 262 | 1.52k | } |
DataStream& DataStream::operator>><bool&>(bool&) Line | Count | Source | 259 | 18.1k | { | 260 | 18.1k | ::Unserialize(*this, obj); | 261 | 18.1k | return (*this); | 262 | 18.1k | } |
DataStream& DataStream::operator>><ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>>>>(ParamsWrapper<CAddress::SerParams, std::vector<CAddress, std::allocator<CAddress>>>&&) Line | Count | Source | 259 | 59 | { | 260 | 59 | ::Unserialize(*this, obj); | 261 | 59 | return (*this); | 262 | 59 | } |
DataStream& DataStream::operator>><std::vector<CInv, std::allocator<CInv>>&>(std::vector<CInv, std::allocator<CInv>>&) Line | Count | Source | 259 | 57.0k | { | 260 | 57.0k | ::Unserialize(*this, obj); | 261 | 57.0k | return (*this); | 262 | 57.0k | } |
DataStream& DataStream::operator>><CBlockLocator&>(CBlockLocator&) Line | Count | Source | 259 | 6.01k | { | 260 | 6.01k | ::Unserialize(*this, obj); | 261 | 6.01k | return (*this); | 262 | 6.01k | } |
DataStream& DataStream::operator>><BlockTransactions&>(BlockTransactions&) Line | Count | Source | 259 | 594 | { | 260 | 594 | ::Unserialize(*this, obj); | 261 | 594 | return (*this); | 262 | 594 | } |
DataStream& DataStream::operator>><CBlockHeader&>(CBlockHeader&) Line | Count | Source | 259 | 556k | { | 260 | 556k | ::Unserialize(*this, obj); | 261 | 556k | return (*this); | 262 | 556k | } |
DataStream& DataStream::operator>><CBloomFilter&>(CBloomFilter&) Line | Count | Source | 259 | 9 | { | 260 | 9 | ::Unserialize(*this, obj); | 261 | 9 | return (*this); | 262 | 9 | } |
DataStream& DataStream::operator>><CDiskBlockIndex&>(CDiskBlockIndex&) Line | Count | Source | 259 | 132k | { | 260 | 132k | ::Unserialize(*this, obj); | 261 | 132k | return (*this); | 262 | 132k | } |
DataStream& DataStream::operator>><std::vector<COutPoint, std::allocator<COutPoint>>&>(std::vector<COutPoint, std::allocator<COutPoint>>&) Line | Count | Source | 259 | 2 | { | 260 | 2 | ::Unserialize(*this, obj); | 261 | 2 | return (*this); | 262 | 2 | } |
DataStream& DataStream::operator>><Coin&>(Coin&) Line | Count | Source | 259 | 221k | { | 260 | 221k | ::Unserialize(*this, obj); | 261 | 221k | return (*this); | 262 | 221k | } |
DataStream& DataStream::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>&&) Line | Count | Source | 259 | 221k | { | 260 | 221k | ::Unserialize(*this, obj); | 261 | 221k | return (*this); | 262 | 221k | } |
DataStream& DataStream::operator>><wallet::CKeyMetadata&>(wallet::CKeyMetadata&) Line | Count | Source | 259 | 271 | { | 260 | 271 | ::Unserialize(*this, obj); | 261 | 271 | return (*this); | 262 | 271 | } |
DataStream& DataStream::operator>><wallet::WalletDescriptor&>(wallet::WalletDescriptor&) Line | Count | Source | 259 | 2.50k | { | 260 | 2.50k | ::Unserialize(*this, obj); | 261 | 2.50k | return (*this); | 262 | 2.50k | } |
DataStream& DataStream::operator>><transaction_identifier<false>&>(transaction_identifier<false>&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
DataStream& DataStream::operator>><wallet::CWalletTx&>(wallet::CWalletTx&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
DataStream& DataStream::operator>><std::vector<uint256, std::allocator<uint256>>&>(std::vector<uint256, std::allocator<uint256>>&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
DataStream& DataStream::operator>><std::vector<wallet::CMerkleTx, std::allocator<wallet::CMerkleTx>>&>(std::vector<wallet::CMerkleTx, std::allocator<wallet::CMerkleTx>>&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
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>>>>>&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
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>>>>>&) Line | Count | Source | 259 | 7.75k | { | 260 | 7.75k | ::Unserialize(*this, obj); | 261 | 7.75k | return (*this); | 262 | 7.75k | } |
DataStream& DataStream::operator>><std::vector<unsigned char, secure_allocator<unsigned char>>&>(std::vector<unsigned char, secure_allocator<unsigned char>>&) Line | Count | Source | 259 | 2.40k | { | 260 | 2.40k | ::Unserialize(*this, obj); | 261 | 2.40k | return (*this); | 262 | 2.40k | } |
DataStream& DataStream::operator>><wallet::CMasterKey&>(wallet::CMasterKey&) Line | Count | Source | 259 | 17 | { | 260 | 17 | ::Unserialize(*this, obj); | 261 | 17 | return (*this); | 262 | 17 | } |
DataStream& DataStream::operator>><wallet::CHDChain&>(wallet::CHDChain&) Line | Count | Source | 259 | 33 | { | 260 | 33 | ::Unserialize(*this, obj); | 261 | 33 | return (*this); | 262 | 33 | } |
|
263 | | |
264 | | /** Compute total memory usage of this object (own memory + any dynamic memory). */ |
265 | | size_t GetMemoryUsage() const noexcept; |
266 | | }; |
267 | | |
268 | | template <typename IStream> |
269 | | class BitStreamReader |
270 | | { |
271 | | private: |
272 | | IStream& m_istream; |
273 | | |
274 | | /// Buffered byte read in from the input stream. A new byte is read into the |
275 | | /// buffer when m_offset reaches 8. |
276 | | uint8_t m_buffer{0}; |
277 | | |
278 | | /// Number of high order bits in m_buffer already returned by previous |
279 | | /// Read() calls. The next bit to be returned is at this offset from the |
280 | | /// most significant bit position. |
281 | | int m_offset{8}; |
282 | | |
283 | | public: |
284 | 1.24k | explicit BitStreamReader(IStream& istream) : m_istream(istream) {}BitStreamReader<DataStream>::BitStreamReader(DataStream&) Line | Count | Source | 284 | 1 | explicit BitStreamReader(IStream& istream) : m_istream(istream) {} |
BitStreamReader<SpanReader>::BitStreamReader(SpanReader&) Line | Count | Source | 284 | 1.24k | explicit BitStreamReader(IStream& istream) : m_istream(istream) {} |
|
285 | | |
286 | | /** Read the specified number of bits from the stream. The data is returned |
287 | | * in the nbits least significant bits of a 64-bit uint. |
288 | | */ |
289 | 25.9k | uint64_t Read(int nbits) { |
290 | 25.9k | if (nbits < 0 || nbits > 64) { |
291 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); |
292 | 0 | } |
293 | | |
294 | 25.9k | uint64_t data = 0; |
295 | 64.9k | while (nbits > 0) { |
296 | 39.0k | if (m_offset == 8) { |
297 | 16.7k | m_istream >> m_buffer; |
298 | 16.7k | m_offset = 0; |
299 | 16.7k | } |
300 | | |
301 | 39.0k | int bits = std::min(8 - m_offset, nbits); |
302 | 39.0k | data <<= bits; |
303 | 39.0k | data |= static_cast<uint8_t>(m_buffer << m_offset) >> (8 - bits); |
304 | 39.0k | m_offset += bits; |
305 | 39.0k | nbits -= bits; |
306 | 39.0k | } |
307 | 25.9k | return data; |
308 | 25.9k | } BitStreamReader<DataStream>::Read(int) Line | Count | Source | 289 | 9 | uint64_t Read(int nbits) { | 290 | 9 | if (nbits < 0 || nbits > 64) { | 291 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); | 292 | 0 | } | 293 | | | 294 | 9 | uint64_t data = 0; | 295 | 24 | while (nbits > 0) { | 296 | 15 | if (m_offset == 8) { | 297 | 7 | m_istream >> m_buffer; | 298 | 7 | m_offset = 0; | 299 | 7 | } | 300 | | | 301 | 15 | int bits = std::min(8 - m_offset, nbits); | 302 | 15 | data <<= bits; | 303 | 15 | data |= static_cast<uint8_t>(m_buffer << m_offset) >> (8 - bits); | 304 | 15 | m_offset += bits; | 305 | 15 | nbits -= bits; | 306 | 15 | } | 307 | 9 | return data; | 308 | 9 | } |
BitStreamReader<SpanReader>::Read(int) Line | Count | Source | 289 | 25.9k | uint64_t Read(int nbits) { | 290 | 25.9k | if (nbits < 0 || nbits > 64) { | 291 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); | 292 | 0 | } | 293 | | | 294 | 25.9k | uint64_t data = 0; | 295 | 64.9k | while (nbits > 0) { | 296 | 39.0k | if (m_offset == 8) { | 297 | 16.7k | m_istream >> m_buffer; | 298 | 16.7k | m_offset = 0; | 299 | 16.7k | } | 300 | | | 301 | 39.0k | int bits = std::min(8 - m_offset, nbits); | 302 | 39.0k | data <<= bits; | 303 | 39.0k | data |= static_cast<uint8_t>(m_buffer << m_offset) >> (8 - bits); | 304 | 39.0k | m_offset += bits; | 305 | 39.0k | nbits -= bits; | 306 | 39.0k | } | 307 | 25.9k | return data; | 308 | 25.9k | } |
|
309 | | }; |
310 | | |
311 | | template <typename OStream> |
312 | | class BitStreamWriter |
313 | | { |
314 | | private: |
315 | | OStream& m_ostream; |
316 | | |
317 | | /// Buffered byte waiting to be written to the output stream. The byte is |
318 | | /// written buffer when m_offset reaches 8 or Flush() is called. |
319 | | uint8_t m_buffer{0}; |
320 | | |
321 | | /// Number of high order bits in m_buffer already written by previous |
322 | | /// Write() calls and not yet flushed to the stream. The next bit to be |
323 | | /// written to is at this offset from the most significant bit position. |
324 | | int m_offset{0}; |
325 | | |
326 | | public: |
327 | 7.67k | explicit BitStreamWriter(OStream& ostream) : m_ostream(ostream) {}BitStreamWriter<DataStream>::BitStreamWriter(DataStream&) Line | Count | Source | 327 | 1 | explicit BitStreamWriter(OStream& ostream) : m_ostream(ostream) {} |
BitStreamWriter<VectorWriter>::BitStreamWriter(VectorWriter&) Line | Count | Source | 327 | 7.67k | explicit BitStreamWriter(OStream& ostream) : m_ostream(ostream) {} |
|
328 | | |
329 | | ~BitStreamWriter() |
330 | 7.67k | { |
331 | 7.67k | Flush(); |
332 | 7.67k | } BitStreamWriter<DataStream>::~BitStreamWriter() Line | Count | Source | 330 | 1 | { | 331 | 1 | Flush(); | 332 | 1 | } |
BitStreamWriter<VectorWriter>::~BitStreamWriter() Line | Count | Source | 330 | 7.67k | { | 331 | 7.67k | Flush(); | 332 | 7.67k | } |
|
333 | | |
334 | | /** Write the nbits least significant bits of a 64-bit int to the output |
335 | | * stream. Data is buffered until it completes an octet. |
336 | | */ |
337 | 18.7k | void Write(uint64_t data, int nbits) { |
338 | 18.7k | if (nbits < 0 || nbits > 64) { |
339 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); |
340 | 0 | } |
341 | | |
342 | 53.8k | while (nbits > 0) { |
343 | 35.0k | int bits = std::min(8 - m_offset, nbits); |
344 | 35.0k | m_buffer |= (data << (64 - nbits)) >> (64 - 8 + m_offset); |
345 | 35.0k | m_offset += bits; |
346 | 35.0k | nbits -= bits; |
347 | | |
348 | 35.0k | if (m_offset == 8) { |
349 | 16.4k | Flush(); |
350 | 16.4k | } |
351 | 35.0k | } |
352 | 18.7k | } BitStreamWriter<DataStream>::Write(unsigned long, int) Line | Count | Source | 337 | 8 | void Write(uint64_t data, int nbits) { | 338 | 8 | if (nbits < 0 || nbits > 64) { | 339 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); | 340 | 0 | } | 341 | | | 342 | 21 | while (nbits > 0) { | 343 | 13 | int bits = std::min(8 - m_offset, nbits); | 344 | 13 | m_buffer |= (data << (64 - nbits)) >> (64 - 8 + m_offset); | 345 | 13 | m_offset += bits; | 346 | 13 | nbits -= bits; | 347 | | | 348 | 13 | if (m_offset == 8) { | 349 | 5 | Flush(); | 350 | 5 | } | 351 | 13 | } | 352 | 8 | } |
BitStreamWriter<VectorWriter>::Write(unsigned long, int) Line | Count | Source | 337 | 18.7k | void Write(uint64_t data, int nbits) { | 338 | 18.7k | if (nbits < 0 || nbits > 64) { | 339 | 0 | throw std::out_of_range("nbits must be between 0 and 64"); | 340 | 0 | } | 341 | | | 342 | 53.8k | while (nbits > 0) { | 343 | 35.0k | int bits = std::min(8 - m_offset, nbits); | 344 | 35.0k | m_buffer |= (data << (64 - nbits)) >> (64 - 8 + m_offset); | 345 | 35.0k | m_offset += bits; | 346 | 35.0k | nbits -= bits; | 347 | | | 348 | 35.0k | if (m_offset == 8) { | 349 | 16.4k | Flush(); | 350 | 16.4k | } | 351 | 35.0k | } | 352 | 18.7k | } |
|
353 | | |
354 | | /** Flush any unwritten bits to the output stream, padding with 0's to the |
355 | | * next byte boundary. |
356 | | */ |
357 | 31.7k | void Flush() { |
358 | 31.7k | if (m_offset == 0) { |
359 | 7.76k | return; |
360 | 7.76k | } |
361 | | |
362 | 24.0k | m_ostream << m_buffer; |
363 | 24.0k | m_buffer = 0; |
364 | 24.0k | m_offset = 0; |
365 | 24.0k | } BitStreamWriter<DataStream>::Flush() Line | Count | Source | 357 | 7 | void Flush() { | 358 | 7 | if (m_offset == 0) { | 359 | 1 | return; | 360 | 1 | } | 361 | | | 362 | 6 | m_ostream << m_buffer; | 363 | 6 | m_buffer = 0; | 364 | 6 | m_offset = 0; | 365 | 6 | } |
BitStreamWriter<VectorWriter>::Flush() Line | Count | Source | 357 | 31.7k | void Flush() { | 358 | 31.7k | if (m_offset == 0) { | 359 | 7.75k | return; | 360 | 7.75k | } | 361 | | | 362 | 24.0k | m_ostream << m_buffer; | 363 | 24.0k | m_buffer = 0; | 364 | 24.0k | m_offset = 0; | 365 | 24.0k | } |
|
366 | | }; |
367 | | |
368 | | /** Non-refcounted RAII wrapper for FILE* |
369 | | * |
370 | | * Will automatically close the file when it goes out of scope if not null. |
371 | | * If you're returning the file pointer, return file.release(). |
372 | | * If you need to close the file early, use autofile.fclose() instead of fclose(underlying_FILE). |
373 | | * |
374 | | * @note If the file has been written to, then the caller must close it |
375 | | * explicitly with the `fclose()` method, check if it returns an error and treat |
376 | | * such an error as if the `write()` method failed. The OS's `fclose(3)` may |
377 | | * fail to flush to disk data that has been previously written, rendering the |
378 | | * file corrupt. |
379 | | */ |
380 | | class AutoFile |
381 | | { |
382 | | protected: |
383 | | std::FILE* m_file; |
384 | | Obfuscation m_obfuscation; |
385 | | std::optional<int64_t> m_position; |
386 | | bool m_was_written{false}; |
387 | | |
388 | | public: |
389 | | explicit AutoFile(std::FILE* file, const Obfuscation& obfuscation = {}); |
390 | | |
391 | | ~AutoFile() |
392 | 418k | { |
393 | 418k | if (m_was_written) { |
394 | | // Callers that wrote to the file must have closed it explicitly |
395 | | // with the fclose() method and checked that the close succeeded. |
396 | | // This is because here in the destructor we have no way to signal |
397 | | // errors from fclose() which, after write, could mean the file is |
398 | | // corrupted and must be handled properly at the call site. |
399 | | // Destructors in C++ cannot signal an error to the callers because |
400 | | // they do not return a value and are not allowed to throw exceptions. |
401 | 218k | Assume(IsNull()); |
402 | 218k | } |
403 | | |
404 | 418k | if (fclose() != 0) { |
405 | 0 | LogError("Failed to close file: %s", SysErrorString(errno)); |
406 | 0 | } |
407 | 418k | } |
408 | | |
409 | | // Disallow copies |
410 | | AutoFile(const AutoFile&) = delete; |
411 | | AutoFile& operator=(const AutoFile&) = delete; |
412 | | |
413 | 240 | bool feof() const { return std::feof(m_file); } |
414 | | |
415 | | [[nodiscard]] int fclose() |
416 | 636k | { |
417 | 636k | if (auto rel{release()}) return std::fclose(rel); |
418 | 219k | return 0; |
419 | 636k | } |
420 | | |
421 | | /** Get wrapped FILE* with transfer of ownership. |
422 | | * @note This will invalidate the AutoFile object, and makes it the responsibility of the caller |
423 | | * of this function to clean up the returned FILE*. |
424 | | */ |
425 | | std::FILE* release() |
426 | 636k | { |
427 | 636k | std::FILE* ret{m_file}; |
428 | 636k | m_file = nullptr; |
429 | 636k | return ret; |
430 | 636k | } |
431 | | |
432 | | /** Return true if the wrapped FILE* is nullptr, false otherwise. |
433 | | */ |
434 | 1.05M | bool IsNull() const { return m_file == nullptr; } |
435 | | |
436 | | /** Continue with a different XOR key */ |
437 | 1.36k | void SetObfuscation(const Obfuscation& obfuscation) { m_obfuscation = obfuscation; } |
438 | | |
439 | | /** Implementation detail, only used internally. */ |
440 | | std::size_t detail_fread(std::span<std::byte> dst); |
441 | | |
442 | | /** Wrapper around fseek(). Will throw if seeking is not possible. */ |
443 | | void seek(int64_t offset, int origin); |
444 | | |
445 | | /** Find position within the file. Will throw if unknown. */ |
446 | | int64_t tell(); |
447 | | |
448 | | /** Return the size of the file. Will throw if unknown. */ |
449 | | int64_t size(); |
450 | | |
451 | | /** Wrapper around FileCommit(). */ |
452 | | bool Commit(); |
453 | | |
454 | | /** Wrapper around TruncateFile(). */ |
455 | | bool Truncate(unsigned size); |
456 | | |
457 | | //! Write a mutable buffer more efficiently than write(), obfuscating the buffer in-place. |
458 | | void write_buffer(std::span<std::byte> src); |
459 | | |
460 | | // |
461 | | // Stream subset |
462 | | // |
463 | | void read(std::span<std::byte> dst); |
464 | | void ignore(size_t nSize); |
465 | | void write(std::span<const std::byte> src); |
466 | | |
467 | | template <typename T> |
468 | | AutoFile& operator<<(const T& obj) |
469 | 40.3M | { |
470 | 40.3M | ::Serialize(*this, obj); |
471 | 40.3M | return *this; |
472 | 40.3M | } AutoFile& AutoFile::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>>&> const&) Line | Count | Source | 469 | 3 | { | 470 | 3 | ::Serialize(*this, obj); | 471 | 3 | return *this; | 472 | 3 | } |
AutoFile& AutoFile::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 | 469 | 3 | { | 470 | 3 | ::Serialize(*this, obj); | 471 | 3 | return *this; | 472 | 3 | } |
AutoFile& AutoFile::operator<<<std::byte>(std::byte const&) Line | Count | Source | 469 | 1 | { | 470 | 1 | ::Serialize(*this, obj); | 471 | 1 | return *this; | 472 | 1 | } |
AutoFile& AutoFile::operator<<<std::vector<unsigned char, std::allocator<unsigned char>>>(std::vector<unsigned char, std::allocator<unsigned char>> const&) Line | Count | Source | 469 | 7.54k | { | 470 | 7.54k | ::Serialize(*this, obj); | 471 | 7.54k | return *this; | 472 | 7.54k | } |
AutoFile& AutoFile::operator<<<unsigned char>(unsigned char const&) Line | Count | Source | 469 | 6.51k | { | 470 | 6.51k | ::Serialize(*this, obj); | 471 | 6.51k | return *this; | 472 | 6.51k | } |
AutoFile& AutoFile::operator<<<uint256>(uint256 const&) Line | Count | Source | 469 | 9.11k | { | 470 | 9.11k | ::Serialize(*this, obj); | 471 | 9.11k | return *this; | 472 | 9.11k | } |
AutoFile& AutoFile::operator<<<std::span<unsigned char const, 32ul>>(std::span<unsigned char const, 32ul> const&) Line | Count | Source | 469 | 16.4k | { | 470 | 16.4k | ::Serialize(*this, obj); | 471 | 16.4k | return *this; | 472 | 16.4k | } |
AutoFile& AutoFile::operator<<<std::span<char const, 18446744073709551615ul>>(std::span<char const, 18446744073709551615ul> const&) Line | Count | Source | 469 | 23 | { | 470 | 23 | ::Serialize(*this, obj); | 471 | 23 | return *this; | 472 | 23 | } |
AutoFile& AutoFile::operator<<<std::span<unsigned char const, 18446744073709551615ul>>(std::span<unsigned char const, 18446744073709551615ul> const&) Line | Count | Source | 469 | 495 | { | 470 | 495 | ::Serialize(*this, obj); | 471 | 495 | return *this; | 472 | 495 | } |
AutoFile& AutoFile::operator<<<std::array<std::byte, 8ul>>(std::array<std::byte, 8ul> const&) Line | Count | Source | 469 | 440 | { | 470 | 440 | ::Serialize(*this, obj); | 471 | 440 | return *this; | 472 | 440 | } |
AutoFile& AutoFile::operator<<<unsigned long>(unsigned long const&) Line | Count | Source | 469 | 40.2M | { | 470 | 40.2M | ::Serialize(*this, obj); | 471 | 40.2M | return *this; | 472 | 40.2M | } |
AutoFile& AutoFile::operator<<<Obfuscation>(Obfuscation const&) Line | Count | Source | 469 | 915 | { | 470 | 915 | ::Serialize(*this, obj); | 471 | 915 | return *this; | 472 | 915 | } |
AutoFile& AutoFile::operator<<<std::vector<std::byte, std::allocator<std::byte>>>(std::vector<std::byte, std::allocator<std::byte>> const&) Line | Count | Source | 469 | 915 | { | 470 | 915 | ::Serialize(*this, obj); | 471 | 915 | return *this; | 472 | 915 | } |
AutoFile& AutoFile::operator<<<ParamsWrapper<TransactionSerParams, CTransaction const>>(ParamsWrapper<TransactionSerParams, CTransaction const> const&) Line | Count | Source | 469 | 1.21k | { | 470 | 1.21k | ::Serialize(*this, obj); | 471 | 1.21k | return *this; | 472 | 1.21k | } |
AutoFile& AutoFile::operator<<<long>(long const&) Line | Count | Source | 469 | 2.42k | { | 470 | 2.42k | ::Serialize(*this, obj); | 471 | 2.42k | return *this; | 472 | 2.42k | } |
AutoFile& AutoFile::operator<<<std::map<transaction_identifier<false>, long, std::less<transaction_identifier<false>>, std::allocator<std::pair<transaction_identifier<false> const, long>>>>(std::map<transaction_identifier<false>, long, std::less<transaction_identifier<false>>, std::allocator<std::pair<transaction_identifier<false> const, long>>> const&) Line | Count | Source | 469 | 916 | { | 470 | 916 | ::Serialize(*this, obj); | 471 | 916 | return *this; | 472 | 916 | } |
AutoFile& AutoFile::operator<<<std::set<transaction_identifier<false>, std::less<transaction_identifier<false>>, std::allocator<transaction_identifier<false>>>>(std::set<transaction_identifier<false>, std::less<transaction_identifier<false>>, std::allocator<transaction_identifier<false>>> const&) Line | Count | Source | 469 | 916 | { | 470 | 916 | ::Serialize(*this, obj); | 471 | 916 | return *this; | 472 | 916 | } |
block_policy_estimator.cpp:AutoFile& AutoFile::operator<<<Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double const&>>(Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double const&> const&) Line | Count | Source | 469 | 3.12k | { | 470 | 3.12k | ::Serialize(*this, obj); | 471 | 3.12k | return *this; | 472 | 3.12k | } |
AutoFile& AutoFile::operator<<<unsigned int>(unsigned int const&) Line | Count | Source | 469 | 6.25k | { | 470 | 6.25k | ::Serialize(*this, obj); | 471 | 6.25k | return *this; | 472 | 6.25k | } |
block_policy_estimator.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 | 469 | 7.30k | { | 470 | 7.30k | ::Serialize(*this, obj); | 471 | 7.30k | return *this; | 472 | 7.30k | } |
block_policy_estimator.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 | 469 | 6.25k | { | 470 | 6.25k | ::Serialize(*this, obj); | 471 | 6.25k | return *this; | 472 | 6.25k | } |
AutoFile& AutoFile::operator<<<int>(int const&) Line | Count | Source | 469 | 1.04k | { | 470 | 1.04k | ::Serialize(*this, obj); | 471 | 1.04k | return *this; | 472 | 1.04k | } |
AutoFile& AutoFile::operator<<<transaction_identifier<false>>(transaction_identifier<false> const&) Line | Count | Source | 469 | 6.55k | { | 470 | 6.55k | ::Serialize(*this, obj); | 471 | 6.55k | return *this; | 472 | 6.55k | } |
AutoFile& AutoFile::operator<<<Coin>(Coin const&) Line | Count | Source | 469 | 6.58k | { | 470 | 6.58k | ::Serialize(*this, obj); | 471 | 6.58k | return *this; | 472 | 6.58k | } |
AutoFile& AutoFile::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&) Line | Count | Source | 469 | 6.58k | { | 470 | 6.58k | ::Serialize(*this, obj); | 471 | 6.58k | return *this; | 472 | 6.58k | } |
AutoFile& AutoFile::operator<<<std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul> const&) Line | Count | Source | 469 | 6.11k | { | 470 | 6.11k | ::Serialize(*this, obj); | 471 | 6.11k | return *this; | 472 | 6.11k | } |
AutoFile& AutoFile::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&) Line | Count | Source | 469 | 472 | { | 470 | 472 | ::Serialize(*this, obj); | 471 | 472 | return *this; | 472 | 472 | } |
AutoFile& AutoFile::operator<<<node::SnapshotMetadata>(node::SnapshotMetadata const&) Line | Count | Source | 469 | 44 | { | 470 | 44 | ::Serialize(*this, obj); | 471 | 44 | return *this; | 472 | 44 | } |
AutoFile& AutoFile::operator<<<std::array<unsigned char, 5ul>>(std::array<unsigned char, 5ul> const&) Line | Count | Source | 469 | 44 | { | 470 | 44 | ::Serialize(*this, obj); | 471 | 44 | return *this; | 472 | 44 | } |
AutoFile& AutoFile::operator<<<unsigned short>(unsigned short const&) Line | Count | Source | 469 | 44 | { | 470 | 44 | ::Serialize(*this, obj); | 471 | 44 | return *this; | 472 | 44 | } |
AutoFile& AutoFile::operator<<<std::array<unsigned char, 4ul>>(std::array<unsigned char, 4ul> const&) Line | Count | Source | 469 | 44 | { | 470 | 44 | ::Serialize(*this, obj); | 471 | 44 | return *this; | 472 | 44 | } |
AutoFile& AutoFile::operator<<<std::span<std::byte const, 1519688ul>>(std::span<std::byte const, 1519688ul> const&) Line | Count | Source | 469 | 1 | { | 470 | 1 | ::Serialize(*this, obj); | 471 | 1 | return *this; | 472 | 1 | } |
|
473 | | |
474 | | template <typename T> |
475 | | AutoFile& operator>>(T&& obj) |
476 | 21.9M | { |
477 | 21.9M | ::Unserialize(*this, obj); |
478 | 21.9M | return *this; |
479 | 21.9M | } AutoFile& AutoFile::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 | 476 | 4 | { | 477 | 4 | ::Unserialize(*this, obj); | 478 | 4 | return *this; | 479 | 4 | } |
AutoFile& AutoFile::operator>><std::byte>(std::byte&&) Line | Count | Source | 476 | 3 | { | 477 | 3 | ::Unserialize(*this, obj); | 478 | 3 | return *this; | 479 | 3 | } |
AutoFile& AutoFile::operator>><std::span<std::byte, 18446744073709551615ul>>(std::span<std::byte, 18446744073709551615ul>&&) Line | Count | Source | 476 | 1 | { | 477 | 1 | ::Unserialize(*this, obj); | 478 | 1 | return *this; | 479 | 1 | } |
AutoFile& AutoFile::operator>><std::vector<std::byte, std::allocator<std::byte>>&>(std::vector<std::byte, std::allocator<std::byte>>&) Line | Count | Source | 476 | 450 | { | 477 | 450 | ::Unserialize(*this, obj); | 478 | 450 | return *this; | 479 | 450 | } |
AutoFile& AutoFile::operator>><unsigned char&>(unsigned char&) Line | Count | Source | 476 | 3.32k | { | 477 | 3.32k | ::Unserialize(*this, obj); | 478 | 3.32k | return *this; | 479 | 3.32k | } |
AutoFile& AutoFile::operator>><node::SnapshotMetadata&>(node::SnapshotMetadata&) Line | Count | Source | 476 | 73 | { | 477 | 73 | ::Unserialize(*this, obj); | 478 | 73 | return *this; | 479 | 73 | } |
AutoFile& AutoFile::operator>><std::array<unsigned char, 5ul>&>(std::array<unsigned char, 5ul>&) Line | Count | Source | 476 | 73 | { | 477 | 73 | ::Unserialize(*this, obj); | 478 | 73 | return *this; | 479 | 73 | } |
AutoFile& AutoFile::operator>><unsigned short&>(unsigned short&) Line | Count | Source | 476 | 5.63k | { | 477 | 5.63k | ::Unserialize(*this, obj); | 478 | 5.63k | return *this; | 479 | 5.63k | } |
AutoFile& AutoFile::operator>><std::array<unsigned char, 4ul>&>(std::array<unsigned char, 4ul>&) Line | Count | Source | 476 | 156k | { | 477 | 156k | ::Unserialize(*this, obj); | 478 | 156k | return *this; | 479 | 156k | } |
AutoFile& AutoFile::operator>><uint256&>(uint256&) Line | Count | Source | 476 | 2.05k | { | 477 | 2.05k | ::Unserialize(*this, obj); | 478 | 2.05k | return *this; | 479 | 2.05k | } |
AutoFile& AutoFile::operator>><unsigned long&>(unsigned long&) Line | Count | Source | 476 | 21.5M | { | 477 | 21.5M | ::Unserialize(*this, obj); | 478 | 21.5M | return *this; | 479 | 21.5M | } |
AutoFile& AutoFile::operator>><transaction_identifier<false>&>(transaction_identifier<false>&) Line | Count | Source | 476 | 6.35k | { | 477 | 6.35k | ::Unserialize(*this, obj); | 478 | 6.35k | return *this; | 479 | 6.35k | } |
AutoFile& AutoFile::operator>><Coin&>(Coin&) Line | Count | Source | 476 | 6.35k | { | 477 | 6.35k | ::Unserialize(*this, obj); | 478 | 6.35k | return *this; | 479 | 6.35k | } |
AutoFile& AutoFile::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>&&) Line | Count | Source | 476 | 6.35k | { | 477 | 6.35k | ::Unserialize(*this, obj); | 478 | 6.35k | return *this; | 479 | 6.35k | } |
AutoFile& AutoFile::operator>><Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>&&) Line | Count | Source | 476 | 6.35k | { | 477 | 6.35k | ::Unserialize(*this, obj); | 478 | 6.35k | return *this; | 479 | 6.35k | } |
AutoFile& AutoFile::operator>><std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul>&&) Line | Count | Source | 476 | 6.35k | { | 477 | 6.35k | ::Unserialize(*this, obj); | 478 | 6.35k | return *this; | 479 | 6.35k | } |
Unexecuted instantiation: AutoFile& AutoFile::operator>><Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>>(Wrapper<CustomUintFormatter<1, false>, AddrManImpl::Format&>&&) AutoFile& AutoFile::operator>><std::vector<unsigned char, std::allocator<unsigned char>>&>(std::vector<unsigned char, std::allocator<unsigned char>>&) Line | Count | Source | 476 | 1.38k | { | 477 | 1.38k | ::Unserialize(*this, obj); | 478 | 1.38k | return *this; | 479 | 1.38k | } |
AutoFile& AutoFile::operator>><CBlockHeader&>(CBlockHeader&) Line | Count | Source | 476 | 162 | { | 477 | 162 | ::Unserialize(*this, obj); | 478 | 162 | return *this; | 479 | 162 | } |
AutoFile& AutoFile::operator>><ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>>(ParamsWrapper<TransactionSerParams, std::shared_ptr<CTransaction const>>&&) Line | Count | Source | 476 | 456 | { | 477 | 456 | ::Unserialize(*this, obj); | 478 | 456 | return *this; | 479 | 456 | } |
AutoFile& AutoFile::operator>><std::array<std::byte, 8ul>&>(std::array<std::byte, 8ul>&) Line | Count | Source | 476 | 752 | { | 477 | 752 | ::Unserialize(*this, obj); | 478 | 752 | return *this; | 479 | 752 | } |
AutoFile& AutoFile::operator>><unsigned int&>(unsigned int&) Line | Count | Source | 476 | 162k | { | 477 | 162k | ::Unserialize(*this, obj); | 478 | 162k | return *this; | 479 | 162k | } |
AutoFile& AutoFile::operator>><Obfuscation&>(Obfuscation&) Line | Count | Source | 476 | 447 | { | 477 | 447 | ::Unserialize(*this, obj); | 478 | 447 | return *this; | 479 | 447 | } |
AutoFile& AutoFile::operator>><long&>(long&) Line | Count | Source | 476 | 588 | { | 477 | 588 | ::Unserialize(*this, obj); | 478 | 588 | return *this; | 479 | 588 | } |
AutoFile& AutoFile::operator>><std::map<transaction_identifier<false>, long, std::less<transaction_identifier<false>>, std::allocator<std::pair<transaction_identifier<false> const, long>>>&>(std::map<transaction_identifier<false>, long, std::less<transaction_identifier<false>>, std::allocator<std::pair<transaction_identifier<false> const, long>>>&) Line | Count | Source | 476 | 448 | { | 477 | 448 | ::Unserialize(*this, obj); | 478 | 448 | return *this; | 479 | 448 | } |
AutoFile& AutoFile::operator>><std::set<transaction_identifier<false>, std::less<transaction_identifier<false>>, std::allocator<transaction_identifier<false>>>&>(std::set<transaction_identifier<false>, std::less<transaction_identifier<false>>, std::allocator<transaction_identifier<false>>>&) Line | Count | Source | 476 | 448 | { | 477 | 448 | ::Unserialize(*this, obj); | 478 | 448 | return *this; | 479 | 448 | } |
block_policy_estimator.cpp:AutoFile& AutoFile::operator>><Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double&>>(Wrapper<(anonymous namespace)::EncodedDoubleFormatter, double&>&&) Line | Count | Source | 476 | 1.67k | { | 477 | 1.67k | ::Unserialize(*this, obj); | 478 | 1.67k | return *this; | 479 | 1.67k | } |
block_policy_estimator.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>>&>&&) Line | Count | Source | 476 | 3.89k | { | 477 | 3.89k | ::Unserialize(*this, obj); | 478 | 3.89k | return *this; | 479 | 3.89k | } |
block_policy_estimator.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>>>>&>&&) Line | Count | Source | 476 | 3.34k | { | 477 | 3.34k | ::Unserialize(*this, obj); | 478 | 3.34k | return *this; | 479 | 3.34k | } |
AutoFile& AutoFile::operator>><int&>(int&) Line | Count | Source | 476 | 557 | { | 477 | 557 | ::Unserialize(*this, obj); | 478 | 557 | return *this; | 479 | 557 | } |
AutoFile& AutoFile::operator>><std::byte&>(std::byte&) Line | Count | Source | 476 | 27 | { | 477 | 27 | ::Unserialize(*this, obj); | 478 | 27 | return *this; | 479 | 27 | } |
AutoFile& AutoFile::operator>><wallet::MetaPage&>(wallet::MetaPage&) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><std::array<std::byte, 20ul>&>(std::array<std::byte, 20ul>&) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><char (&) [368]>(char (&) [368]) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><char (&) [12]>(char (&) [12]) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><unsigned char (&) [20]>(unsigned char (&) [20]) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><unsigned char (&) [16]>(unsigned char (&) [16]) Line | Count | Source | 476 | 92 | { | 477 | 92 | ::Unserialize(*this, obj); | 478 | 92 | return *this; | 479 | 92 | } |
AutoFile& AutoFile::operator>><wallet::PageHeader&>(wallet::PageHeader&) Line | Count | Source | 476 | 133 | { | 477 | 133 | ::Unserialize(*this, obj); | 478 | 133 | return *this; | 479 | 133 | } |
AutoFile& AutoFile::operator>><wallet::RecordsPage&>(wallet::RecordsPage&) Line | Count | Source | 476 | 119 | { | 477 | 119 | ::Unserialize(*this, obj); | 478 | 119 | return *this; | 479 | 119 | } |
AutoFile& AutoFile::operator>><wallet::RecordHeader&>(wallet::RecordHeader&) Line | Count | Source | 476 | 2.64k | { | 477 | 2.64k | ::Unserialize(*this, obj); | 478 | 2.64k | return *this; | 479 | 2.64k | } |
AutoFile& AutoFile::operator>><wallet::DataRecord&>(wallet::DataRecord&) Line | Count | Source | 476 | 2.60k | { | 477 | 2.60k | ::Unserialize(*this, obj); | 478 | 2.60k | return *this; | 479 | 2.60k | } |
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::OverflowRecord&>(wallet::OverflowRecord&) AutoFile& AutoFile::operator>><wallet::InternalPage&>(wallet::InternalPage&) Line | Count | Source | 476 | 14 | { | 477 | 14 | ::Unserialize(*this, obj); | 478 | 14 | return *this; | 479 | 14 | } |
AutoFile& AutoFile::operator>><wallet::InternalRecord&>(wallet::InternalRecord&) Line | Count | Source | 476 | 41 | { | 477 | 41 | ::Unserialize(*this, obj); | 478 | 41 | return *this; | 479 | 41 | } |
Unexecuted instantiation: AutoFile& AutoFile::operator>><wallet::OverflowPage&>(wallet::OverflowPage&) |
480 | | }; |
481 | | |
482 | | using DataBuffer = std::vector<std::byte>; |
483 | | |
484 | | /** Wrapper around an AutoFile& that implements a ring buffer to |
485 | | * deserialize from. It guarantees the ability to rewind a given number of bytes. |
486 | | * |
487 | | * Will automatically close the file when it goes out of scope if not null. |
488 | | * If you need to close the file early, use file.fclose() instead of fclose(file). |
489 | | */ |
490 | | class BufferedFile |
491 | | { |
492 | | private: |
493 | | AutoFile& m_src; |
494 | | uint64_t nSrcPos{0}; //!< how many bytes have been read from source |
495 | | uint64_t m_read_pos{0}; //!< how many bytes have been read from this |
496 | | uint64_t nReadLimit; //!< up to which position we're allowed to read |
497 | | uint64_t nRewind; //!< how many bytes we guarantee to rewind |
498 | | DataBuffer vchBuf; |
499 | | |
500 | | //! read data from the source to fill the buffer |
501 | 391 | bool Fill() { |
502 | 391 | unsigned int pos = nSrcPos % vchBuf.size(); |
503 | 391 | unsigned int readNow = vchBuf.size() - pos; |
504 | 391 | unsigned int nAvail = vchBuf.size() - (nSrcPos - m_read_pos) - nRewind; |
505 | 391 | if (nAvail < readNow) |
506 | 328 | readNow = nAvail; |
507 | 391 | if (readNow == 0) |
508 | 0 | return false; |
509 | 391 | size_t nBytes{m_src.detail_fread(std::span{vchBuf}.subspan(pos, readNow))}; |
510 | 391 | if (nBytes == 0) { |
511 | 14 | throw std::ios_base::failure{m_src.feof() ? "BufferedFile::Fill: end of file" : "BufferedFile::Fill: fread failed"}; |
512 | 14 | } |
513 | 377 | nSrcPos += nBytes; |
514 | 377 | return true; |
515 | 391 | } |
516 | | |
517 | | //! Advance the stream's read pointer (m_read_pos) by up to 'length' bytes, |
518 | | //! filling the buffer from the file so that at least one byte is available. |
519 | | //! Return a pointer to the available buffer data and the number of bytes |
520 | | //! (which may be less than the requested length) that may be accessed |
521 | | //! beginning at that pointer. |
522 | | std::pair<std::byte*, size_t> AdvanceStream(size_t length) |
523 | 8.44M | { |
524 | 8.44M | assert(m_read_pos <= nSrcPos); |
525 | 8.44M | if (m_read_pos + length > nReadLimit) { |
526 | 2 | throw std::ios_base::failure("Attempt to position past buffer limit"); |
527 | 2 | } |
528 | | // If there are no bytes available, read from the file. |
529 | 8.44M | if (m_read_pos == nSrcPos && length > 0) Fill(); |
530 | | |
531 | 8.44M | size_t buffer_offset{static_cast<size_t>(m_read_pos % vchBuf.size())}; |
532 | 8.44M | size_t buffer_available{static_cast<size_t>(vchBuf.size() - buffer_offset)}; |
533 | 8.44M | size_t bytes_until_source_pos{static_cast<size_t>(nSrcPos - m_read_pos)}; |
534 | 8.44M | size_t advance{std::min({length, buffer_available, bytes_until_source_pos})}; |
535 | 8.44M | m_read_pos += advance; |
536 | 8.44M | return std::make_pair(&vchBuf[buffer_offset], advance); |
537 | 8.44M | } |
538 | | |
539 | | public: |
540 | | BufferedFile(AutoFile& file LIFETIMEBOUND, uint64_t nBufSize, uint64_t nRewindIn) |
541 | 69 | : m_src{file}, nReadLimit{std::numeric_limits<uint64_t>::max()}, nRewind{nRewindIn}, vchBuf(nBufSize, std::byte{0}) |
542 | 69 | { |
543 | 69 | if (nRewindIn >= nBufSize) |
544 | 1 | throw std::ios_base::failure("Rewind limit must be less than buffer size"); |
545 | 69 | } |
546 | | |
547 | | //! check whether we're at the end of the source file |
548 | 8.38M | bool eof() const { |
549 | 8.38M | return m_read_pos == nSrcPos && m_src.feof(); |
550 | 8.38M | } |
551 | | |
552 | | //! read a number of bytes |
553 | | void read(std::span<std::byte> dst) |
554 | 8.44M | { |
555 | 16.8M | while (dst.size() > 0) { |
556 | 8.44M | auto [buffer_pointer, length]{AdvanceStream(dst.size())}; |
557 | 8.44M | memcpy(dst.data(), buffer_pointer, length); |
558 | 8.44M | dst = dst.subspan(length); |
559 | 8.44M | } |
560 | 8.44M | } |
561 | | |
562 | | //! Move the read position ahead in the stream to the given position. |
563 | | //! Use SetPos() to back up in the stream, not SkipTo(). |
564 | | void SkipTo(const uint64_t file_pos) |
565 | 2.58k | { |
566 | 2.58k | assert(file_pos >= m_read_pos); |
567 | 5.06k | while (m_read_pos < file_pos) AdvanceStream(file_pos - m_read_pos); |
568 | 2.58k | } |
569 | | |
570 | | //! return the current reading position |
571 | 8.39M | uint64_t GetPos() const { |
572 | 8.39M | return m_read_pos; |
573 | 8.39M | } |
574 | | |
575 | | //! rewind to a given reading position |
576 | 8.38M | bool SetPos(uint64_t nPos) { |
577 | 8.38M | size_t bufsize = vchBuf.size(); |
578 | 8.38M | if (nPos + bufsize < nSrcPos) { |
579 | | // rewinding too far, rewind as far as possible |
580 | 67 | m_read_pos = nSrcPos - bufsize; |
581 | 67 | return false; |
582 | 67 | } |
583 | 8.38M | if (nPos > nSrcPos) { |
584 | | // can't go this far forward, go as far as possible |
585 | 17 | m_read_pos = nSrcPos; |
586 | 17 | return false; |
587 | 17 | } |
588 | 8.38M | m_read_pos = nPos; |
589 | 8.38M | return true; |
590 | 8.38M | } |
591 | | |
592 | | //! prevent reading beyond a certain position |
593 | | //! no argument removes the limit |
594 | 8.38M | bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) { |
595 | 8.38M | if (nPos < m_read_pos) |
596 | 0 | return false; |
597 | 8.38M | nReadLimit = nPos; |
598 | 8.38M | return true; |
599 | 8.38M | } |
600 | | |
601 | | template<typename T> |
602 | 8.39M | BufferedFile& operator>>(T&& obj) { |
603 | 8.39M | ::Unserialize(*this, obj); |
604 | 8.39M | return (*this); |
605 | 8.39M | } BufferedFile& BufferedFile::operator>><unsigned char&>(unsigned char&) Line | Count | Source | 602 | 671 | BufferedFile& operator>>(T&& obj) { | 603 | 671 | ::Unserialize(*this, obj); | 604 | 671 | return (*this); | 605 | 671 | } |
BufferedFile& BufferedFile::operator>><unsigned char (&) [29]>(unsigned char (&) [29]) Line | Count | Source | 602 | 1 | BufferedFile& operator>>(T&& obj) { | 603 | 1 | ::Unserialize(*this, obj); | 604 | 1 | return (*this); | 605 | 1 | } |
BufferedFile& BufferedFile::operator>><unsigned char (&) [1]>(unsigned char (&) [1]) Line | Count | Source | 602 | 644 | BufferedFile& operator>>(T&& obj) { | 603 | 644 | ::Unserialize(*this, obj); | 604 | 644 | return (*this); | 605 | 644 | } |
BufferedFile& BufferedFile::operator>><unsigned char (&) [2]>(unsigned char (&) [2]) Line | Count | Source | 602 | 635 | BufferedFile& operator>>(T&& obj) { | 603 | 635 | ::Unserialize(*this, obj); | 604 | 635 | return (*this); | 605 | 635 | } |
BufferedFile& BufferedFile::operator>><unsigned char (&) [5]>(unsigned char (&) [5]) Line | Count | Source | 602 | 647 | BufferedFile& operator>>(T&& obj) { | 603 | 647 | ::Unserialize(*this, obj); | 604 | 647 | return (*this); | 605 | 647 | } |
BufferedFile& BufferedFile::operator>><std::array<unsigned char, 4ul>&>(std::array<unsigned char, 4ul>&) Line | Count | Source | 602 | 8.38M | BufferedFile& operator>>(T&& obj) { | 603 | 8.38M | ::Unserialize(*this, obj); | 604 | 8.38M | return (*this); | 605 | 8.38M | } |
BufferedFile& BufferedFile::operator>><unsigned int&>(unsigned int&) Line | Count | Source | 602 | 1.96k | BufferedFile& operator>>(T&& obj) { | 603 | 1.96k | ::Unserialize(*this, obj); | 604 | 1.96k | return (*this); | 605 | 1.96k | } |
BufferedFile& BufferedFile::operator>><CBlockHeader&>(CBlockHeader&) Line | Count | Source | 602 | 1.96k | BufferedFile& operator>>(T&& obj) { | 603 | 1.96k | ::Unserialize(*this, obj); | 604 | 1.96k | return (*this); | 605 | 1.96k | } |
BufferedFile& BufferedFile::operator>><ParamsWrapper<TransactionSerParams, CBlock>>(ParamsWrapper<TransactionSerParams, CBlock>&&) Line | Count | Source | 602 | 1.74k | BufferedFile& operator>>(T&& obj) { | 603 | 1.74k | ::Unserialize(*this, obj); | 604 | 1.74k | return (*this); | 605 | 1.74k | } |
|
606 | | |
607 | | //! search for a given byte in the stream, and remain positioned on it |
608 | | void FindByte(std::byte byte) |
609 | 8.38M | { |
610 | | // For best performance, avoid mod operation within the loop. |
611 | 8.38M | size_t buf_offset{size_t(m_read_pos % uint64_t(vchBuf.size()))}; |
612 | 8.38M | while (true) { |
613 | 8.38M | if (m_read_pos == nSrcPos) { |
614 | | // No more bytes available; read from the file into the buffer, |
615 | | // setting nSrcPos to one beyond the end of the new data. |
616 | | // Throws exception if end-of-file reached. |
617 | 167 | Fill(); |
618 | 167 | } |
619 | 8.38M | const size_t len{std::min<size_t>(vchBuf.size() - buf_offset, nSrcPos - m_read_pos)}; |
620 | 8.38M | const auto it_start{vchBuf.begin() + buf_offset}; |
621 | 8.38M | const auto it_find{std::find(it_start, it_start + len, byte)}; |
622 | 8.38M | const size_t inc{size_t(std::distance(it_start, it_find))}; |
623 | 8.38M | m_read_pos += inc; |
624 | 8.38M | if (inc < len) break; |
625 | 154 | buf_offset += inc; |
626 | 154 | if (buf_offset >= vchBuf.size()) buf_offset = 0; |
627 | 154 | } |
628 | 8.38M | } |
629 | | }; |
630 | | |
631 | | /** |
632 | | * Wrapper that buffers reads from an underlying stream. |
633 | | * Requires underlying stream to support read() and detail_fread() calls |
634 | | * to support fixed-size and variable-sized reads, respectively. |
635 | | */ |
636 | | template <typename S> |
637 | | class BufferedReader |
638 | | { |
639 | | S& m_src; |
640 | | DataBuffer m_buf; |
641 | | size_t m_buf_pos; |
642 | | |
643 | | public: |
644 | | //! Requires stream ownership to prevent leaving the stream at an unexpected position after buffered reads. |
645 | | explicit BufferedReader(S&& stream LIFETIMEBOUND, size_t size = 1 << 16) |
646 | | requires std::is_rvalue_reference_v<S&&> |
647 | 36.8k | : m_src{stream}, m_buf(size), m_buf_pos{size} {} |
648 | | |
649 | | void read(std::span<std::byte> dst) |
650 | 303k | { |
651 | 303k | if (const auto available{std::min(dst.size(), m_buf.size() - m_buf_pos)}) { |
652 | 266k | std::copy_n(m_buf.begin() + m_buf_pos, available, dst.begin()); |
653 | 266k | m_buf_pos += available; |
654 | 266k | dst = dst.subspan(available); |
655 | 266k | } |
656 | 303k | if (dst.size()) { |
657 | 36.8k | assert(m_buf_pos == m_buf.size()); |
658 | 36.8k | m_src.read(dst); |
659 | | |
660 | 36.8k | m_buf_pos = 0; |
661 | 36.8k | m_buf.resize(m_src.detail_fread(m_buf)); |
662 | 36.8k | } |
663 | 303k | } |
664 | | |
665 | | template <typename T> |
666 | | BufferedReader& operator>>(T&& obj) |
667 | 36.8k | { |
668 | 36.8k | Unserialize(*this, obj); |
669 | 36.8k | return *this; |
670 | 36.8k | } BufferedReader<AutoFile>& BufferedReader<AutoFile>::operator>><unsigned int&>(unsigned int&) Line | Count | Source | 667 | 2 | { | 668 | 2 | Unserialize(*this, obj); | 669 | 2 | return *this; | 670 | 2 | } |
BufferedReader<AutoFile>& BufferedReader<AutoFile>::operator>><uint256&>(uint256&) Line | Count | Source | 667 | 36.8k | { | 668 | 36.8k | Unserialize(*this, obj); | 669 | 36.8k | return *this; | 670 | 36.8k | } |
|
671 | | }; |
672 | | |
673 | | /** |
674 | | * Wrapper that buffers writes to an underlying stream. |
675 | | * Requires underlying stream to support write_buffer() method |
676 | | * for efficient buffer flushing and obfuscation. |
677 | | */ |
678 | | template <typename S> |
679 | | class BufferedWriter |
680 | | { |
681 | | S& m_dst; |
682 | | DataBuffer m_buf; |
683 | | size_t m_buf_pos{0}; |
684 | | |
685 | | public: |
686 | 206k | explicit BufferedWriter(S& stream LIFETIMEBOUND, size_t size = 1 << 16) : m_dst{stream}, m_buf(size) {} |
687 | | |
688 | 206k | ~BufferedWriter() { flush(); } |
689 | | |
690 | | void flush() |
691 | 224k | { |
692 | 224k | if (m_buf_pos) m_dst.write_buffer(std::span{m_buf}.first(m_buf_pos)); |
693 | 224k | m_buf_pos = 0; |
694 | 224k | } |
695 | | |
696 | | void write(std::span<const std::byte> src) |
697 | 6.09M | { |
698 | 12.2M | while (const auto available{std::min(src.size(), m_buf.size() - m_buf_pos)}) { |
699 | 6.11M | std::copy_n(src.begin(), available, m_buf.begin() + m_buf_pos); |
700 | 6.11M | m_buf_pos += available; |
701 | 6.11M | if (m_buf_pos == m_buf.size()) flush(); |
702 | 6.11M | src = src.subspan(available); |
703 | 6.11M | } |
704 | 6.09M | } |
705 | | |
706 | | template <typename T> |
707 | | BufferedWriter& operator<<(const T& obj) |
708 | 1.01M | { |
709 | 1.01M | Serialize(*this, obj); |
710 | 1.01M | return *this; |
711 | 1.01M | } BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<unsigned int>(unsigned int const&) Line | Count | Source | 708 | 206k | { | 709 | 206k | Serialize(*this, obj); | 710 | 206k | return *this; | 711 | 206k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<std::array<unsigned char, 4ul>>(std::array<unsigned char, 4ul> const&) Line | Count | Source | 708 | 206k | { | 709 | 206k | Serialize(*this, obj); | 710 | 206k | return *this; | 711 | 206k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<CBlockUndo>(CBlockUndo const&) Line | Count | Source | 708 | 102k | { | 709 | 102k | Serialize(*this, obj); | 710 | 102k | return *this; | 711 | 102k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned long&> const&) Line | Count | Source | 708 | 67.6k | { | 709 | 67.6k | Serialize(*this, obj); | 710 | 67.6k | return *this; | 711 | 67.6k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<std::span<unsigned char, 18446744073709551615ul>>(std::span<unsigned char, 18446744073709551615ul> const&) Line | Count | Source | 708 | 8.90k | { | 709 | 8.90k | Serialize(*this, obj); | 710 | 8.90k | return *this; | 711 | 8.90k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&>>(Wrapper<VarIntFormatter<(VarIntMode)0>, unsigned int&> const&) Line | Count | Source | 708 | 58.7k | { | 709 | 58.7k | Serialize(*this, obj); | 710 | 58.7k | return *this; | 711 | 58.7k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<std::span<unsigned char const, 18446744073709551615ul>>(std::span<unsigned char const, 18446744073709551615ul> const&) Line | Count | Source | 708 | 58.7k | { | 709 | 58.7k | Serialize(*this, obj); | 710 | 58.7k | return *this; | 711 | 58.7k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<uint256>(uint256 const&) Line | Count | Source | 708 | 102k | { | 709 | 102k | Serialize(*this, obj); | 710 | 102k | return *this; | 711 | 102k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<std::span<unsigned char const, 32ul>>(std::span<unsigned char const, 32ul> const&) Line | Count | Source | 708 | 102k | { | 709 | 102k | Serialize(*this, obj); | 710 | 102k | return *this; | 711 | 102k | } |
BufferedWriter<AutoFile>& BufferedWriter<AutoFile>::operator<<<ParamsWrapper<TransactionSerParams, CBlock const>>(ParamsWrapper<TransactionSerParams, CBlock const> const&) Line | Count | Source | 708 | 104k | { | 709 | 104k | Serialize(*this, obj); | 710 | 104k | return *this; | 711 | 104k | } |
|
712 | | }; |
713 | | |
714 | | #endif // BITCOIN_STREAMS_H |