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_UNDO_H |
7 | | #define BITCOIN_UNDO_H |
8 | | |
9 | | #include <coins.h> |
10 | | #include <compressor.h> |
11 | | #include <consensus/consensus.h> |
12 | | #include <primitives/transaction.h> |
13 | | #include <serialize.h> |
14 | | |
15 | | /** Formatter for undo information for a CTxIn |
16 | | * |
17 | | * Contains the prevout's CTxOut being spent, and its metadata as well |
18 | | * (coinbase or not, height). The serialization contains a dummy value of |
19 | | * zero. This is compatible with older versions which expect to see |
20 | | * the transaction version there. |
21 | | */ |
22 | | struct TxInUndoFormatter |
23 | | { |
24 | | template<typename Stream> |
25 | 1.63M | void Ser(Stream &s, const Coin& txout) { |
26 | 1.63M | uint32_t nCode{(uint32_t{txout.nHeight} << 1) | uint32_t{txout.fCoinBase}}; |
27 | 1.63M | ::Serialize(s, VARINT(nCode)); |
28 | 1.63M | if (txout.nHeight > 0) { Branch (28:13): [True: 807k, False: 826k]
Branch (28:13): [True: 992, False: 0]
Branch (28:13): [True: 992, False: 0]
Branch (28:13): [True: 992, False: 0]
|
29 | | // Required to maintain compatibility with older undo format. |
30 | 810k | ::Serialize(s, (unsigned char)0); |
31 | 810k | } |
32 | 1.63M | ::Serialize(s, Using<TxOutCompression>(txout.out)); |
33 | 1.63M | } _ZN17TxInUndoFormatter3SerI10DataStreamEEvRT_RK4Coin Line | Count | Source | 25 | 1.63M | void Ser(Stream &s, const Coin& txout) { | 26 | 1.63M | uint32_t nCode{(uint32_t{txout.nHeight} << 1) | uint32_t{txout.fCoinBase}}; | 27 | 1.63M | ::Serialize(s, VARINT(nCode)); | 28 | 1.63M | if (txout.nHeight > 0) { Branch (28:13): [True: 807k, False: 826k]
| 29 | | // Required to maintain compatibility with older undo format. | 30 | 807k | ::Serialize(s, (unsigned char)0); | 31 | 807k | } | 32 | 1.63M | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 33 | 1.63M | } |
_ZN17TxInUndoFormatter3SerI12SizeComputerEEvRT_RK4Coin Line | Count | Source | 25 | 992 | void Ser(Stream &s, const Coin& txout) { | 26 | 992 | uint32_t nCode{(uint32_t{txout.nHeight} << 1) | uint32_t{txout.fCoinBase}}; | 27 | 992 | ::Serialize(s, VARINT(nCode)); | 28 | 992 | if (txout.nHeight > 0) { Branch (28:13): [True: 992, False: 0]
| 29 | | // Required to maintain compatibility with older undo format. | 30 | 992 | ::Serialize(s, (unsigned char)0); | 31 | 992 | } | 32 | 992 | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 33 | 992 | } |
_ZN17TxInUndoFormatter3SerI10HashWriterEEvRT_RK4Coin Line | Count | Source | 25 | 992 | void Ser(Stream &s, const Coin& txout) { | 26 | 992 | uint32_t nCode{(uint32_t{txout.nHeight} << 1) | uint32_t{txout.fCoinBase}}; | 27 | 992 | ::Serialize(s, VARINT(nCode)); | 28 | 992 | if (txout.nHeight > 0) { Branch (28:13): [True: 992, False: 0]
| 29 | | // Required to maintain compatibility with older undo format. | 30 | 992 | ::Serialize(s, (unsigned char)0); | 31 | 992 | } | 32 | 992 | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 33 | 992 | } |
_ZN17TxInUndoFormatter3SerI14BufferedWriterI8AutoFileEEEvRT_RK4Coin Line | Count | Source | 25 | 992 | void Ser(Stream &s, const Coin& txout) { | 26 | 992 | uint32_t nCode{(uint32_t{txout.nHeight} << 1) | uint32_t{txout.fCoinBase}}; | 27 | 992 | ::Serialize(s, VARINT(nCode)); | 28 | 992 | if (txout.nHeight > 0) { Branch (28:13): [True: 992, False: 0]
| 29 | | // Required to maintain compatibility with older undo format. | 30 | 992 | ::Serialize(s, (unsigned char)0); | 31 | 992 | } | 32 | 992 | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 33 | 992 | } |
|
34 | | |
35 | | template<typename Stream> |
36 | 2.68M | void Unser(Stream &s, Coin& txout) { |
37 | 2.68M | uint32_t nCode = 0; |
38 | 2.68M | ::Unserialize(s, VARINT(nCode)); |
39 | 2.68M | txout.nHeight = nCode >> 1; |
40 | 2.68M | txout.fCoinBase = nCode & 1; |
41 | 2.68M | if (txout.nHeight > 0) { Branch (41:13): [True: 1.33M, False: 1.35M]
Branch (41:13): [True: 0, False: 0]
|
42 | | // Old versions stored the version number for the last spend of |
43 | | // a transaction's outputs. Non-final spends were indicated with |
44 | | // height = 0. |
45 | 1.33M | unsigned int nVersionDummy; |
46 | 1.33M | ::Unserialize(s, VARINT(nVersionDummy)); |
47 | 1.33M | } |
48 | 2.68M | ::Unserialize(s, Using<TxOutCompression>(txout.out)); |
49 | 2.68M | } _ZN17TxInUndoFormatter5UnserI10SpanReaderEEvRT_R4Coin Line | Count | Source | 36 | 2.68M | void Unser(Stream &s, Coin& txout) { | 37 | 2.68M | uint32_t nCode = 0; | 38 | 2.68M | ::Unserialize(s, VARINT(nCode)); | 39 | 2.68M | txout.nHeight = nCode >> 1; | 40 | 2.68M | txout.fCoinBase = nCode & 1; | 41 | 2.68M | if (txout.nHeight > 0) { Branch (41:13): [True: 1.33M, False: 1.35M]
| 42 | | // Old versions stored the version number for the last spend of | 43 | | // a transaction's outputs. Non-final spends were indicated with | 44 | | // height = 0. | 45 | 1.33M | unsigned int nVersionDummy; | 46 | 1.33M | ::Unserialize(s, VARINT(nVersionDummy)); | 47 | 1.33M | } | 48 | 2.68M | ::Unserialize(s, Using<TxOutCompression>(txout.out)); | 49 | 2.68M | } |
Unexecuted instantiation: _ZN17TxInUndoFormatter5UnserI12HashVerifierI14BufferedReaderI8AutoFileEEEEvRT_R4Coin |
50 | | }; |
51 | | |
52 | | /** Undo information for a CTransaction */ |
53 | | class CTxUndo |
54 | | { |
55 | | public: |
56 | | // undo information for all txins |
57 | | std::vector<Coin> vprevout; |
58 | | |
59 | 8.63M | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); }_ZN7CTxUndo16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 59 | 6.35M | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } |
_ZN7CTxUndo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 59 | 2.28M | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } |
Unexecuted instantiation: _ZN7CTxUndo16SerializationOpsI12HashVerifierI14BufferedReaderI8AutoFileEES_17ActionUnserializeEEvRT0_RT_T1_ _ZN7CTxUndo16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 59 | 562 | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } |
_ZN7CTxUndo16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 59 | 562 | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } |
_ZN7CTxUndo16SerializationOpsI14BufferedWriterI8AutoFileEKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 59 | 562 | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } |
|
60 | | }; |
61 | | |
62 | | /** Undo information for a CBlock */ |
63 | | class CBlockUndo |
64 | | { |
65 | | public: |
66 | | std::vector<CTxUndo> vtxundo; // for all but the coinbase |
67 | | |
68 | 1.02M | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); }_ZN10CBlockUndo16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 68 | 177 | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } |
_ZN10CBlockUndo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 68 | 125 | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } |
Unexecuted instantiation: _ZN10CBlockUndo16SerializationOpsI12HashVerifierI14BufferedReaderI8AutoFileEES_17ActionUnserializeEEvRT0_RT_T1_ _ZN10CBlockUndo16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 68 | 341k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } |
_ZN10CBlockUndo16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 68 | 341k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } |
_ZN10CBlockUndo16SerializationOpsI14BufferedWriterI8AutoFileEKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 68 | 341k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } |
|
69 | | }; |
70 | | |
71 | | #endif // BITCOIN_UNDO_H |