/Users/eugenesiegel/btc/bitcoin/src/undo.h
Line | Count | Source |
1 | | // Copyright (c) 2009-2010 Satoshi Nakamoto |
2 | | // Copyright (c) 2009-2020 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 | 48.8k | void Ser(Stream &s, const Coin& txout) { |
26 | 48.8k | ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 0 | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
|
27 | 48.8k | if (txout.nHeight > 0) { |
28 | | // Required to maintain compatibility with older undo format. |
29 | 48.8k | ::Serialize(s, (unsigned char)0); |
30 | 48.8k | } |
31 | 48.8k | ::Serialize(s, Using<TxOutCompression>(txout.out)); |
32 | 48.8k | } Unexecuted instantiation: _ZN17TxInUndoFormatter3SerI10DataStreamEEvRT_RK4Coin _ZN17TxInUndoFormatter3SerI12SizeComputerEEvRT_RK4Coin Line | Count | Source | 25 | 16.2k | void Ser(Stream &s, const Coin& txout) { | 26 | 16.2k | ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| 27 | 16.2k | if (txout.nHeight > 0) { | 28 | | // Required to maintain compatibility with older undo format. | 29 | 16.2k | ::Serialize(s, (unsigned char)0); | 30 | 16.2k | } | 31 | 16.2k | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 32 | 16.2k | } |
_ZN17TxInUndoFormatter3SerI10HashWriterEEvRT_RK4Coin Line | Count | Source | 25 | 16.2k | void Ser(Stream &s, const Coin& txout) { | 26 | 16.2k | ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| 27 | 16.2k | if (txout.nHeight > 0) { | 28 | | // Required to maintain compatibility with older undo format. | 29 | 16.2k | ::Serialize(s, (unsigned char)0); | 30 | 16.2k | } | 31 | 16.2k | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 32 | 16.2k | } |
_ZN17TxInUndoFormatter3SerI14BufferedWriterI8AutoFileEEEvRT_RK4Coin Line | Count | Source | 25 | 16.2k | void Ser(Stream &s, const Coin& txout) { | 26 | 16.2k | ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase )); Line | Count | Source | 491 | 16.2k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| 27 | 16.2k | if (txout.nHeight > 0) { | 28 | | // Required to maintain compatibility with older undo format. | 29 | 16.2k | ::Serialize(s, (unsigned char)0); | 30 | 16.2k | } | 31 | 16.2k | ::Serialize(s, Using<TxOutCompression>(txout.out)); | 32 | 16.2k | } |
|
33 | | |
34 | | template<typename Stream> |
35 | 5.82k | void Unser(Stream &s, Coin& txout) { |
36 | 5.82k | uint32_t nCode = 0; |
37 | 5.82k | ::Unserialize(s, VARINT(nCode)); Line | Count | Source | 491 | 0 | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| ::Unserialize(s, VARINT(nCode)); Line | Count | Source | 491 | 5.82k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
|
38 | 5.82k | txout.nHeight = nCode >> 1; |
39 | 5.82k | txout.fCoinBase = nCode & 1; |
40 | 5.82k | if (txout.nHeight > 0) { |
41 | | // Old versions stored the version number for the last spend of |
42 | | // a transaction's outputs. Non-final spends were indicated with |
43 | | // height = 0. |
44 | 5.82k | unsigned int nVersionDummy; |
45 | 5.82k | ::Unserialize(s, VARINT(nVersionDummy)); Line | Count | Source | 491 | 0 | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| ::Unserialize(s, VARINT(nVersionDummy)); Line | Count | Source | 491 | 5.82k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
|
46 | 5.82k | } |
47 | 5.82k | ::Unserialize(s, Using<TxOutCompression>(txout.out)); |
48 | 5.82k | } Unexecuted instantiation: _ZN17TxInUndoFormatter5UnserI10DataStreamEEvRT_R4Coin _ZN17TxInUndoFormatter5UnserI12HashVerifierI14BufferedReaderI8AutoFileEEEEvRT_R4Coin Line | Count | Source | 35 | 5.82k | void Unser(Stream &s, Coin& txout) { | 36 | 5.82k | uint32_t nCode = 0; | 37 | 5.82k | ::Unserialize(s, VARINT(nCode)); Line | Count | Source | 491 | 5.82k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| 38 | 5.82k | txout.nHeight = nCode >> 1; | 39 | 5.82k | txout.fCoinBase = nCode & 1; | 40 | 5.82k | if (txout.nHeight > 0) { | 41 | | // Old versions stored the version number for the last spend of | 42 | | // a transaction's outputs. Non-final spends were indicated with | 43 | | // height = 0. | 44 | 5.82k | unsigned int nVersionDummy; | 45 | 5.82k | ::Unserialize(s, VARINT(nVersionDummy)); Line | Count | Source | 491 | 5.82k | #define VARINT(obj) Using<VarIntFormatter<VarIntMode::DEFAULT>>(obj) |
| 46 | 5.82k | } | 47 | 5.82k | ::Unserialize(s, Using<TxOutCompression>(txout.out)); | 48 | 5.82k | } |
|
49 | | }; |
50 | | |
51 | | /** Undo information for a CTransaction */ |
52 | | class CTxUndo |
53 | | { |
54 | | public: |
55 | | // undo information for all txins |
56 | | std::vector<Coin> vprevout; |
57 | | |
58 | 54.6k | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 0 | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 0 | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 5.82k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
Unexecuted instantiation: _ZN7CTxUndo16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_ Unexecuted instantiation: _ZN7CTxUndo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_ _ZN7CTxUndo16SerializationOpsI12HashVerifierI14BufferedReaderI8AutoFileEES_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 58 | 5.82k | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 5.82k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN7CTxUndo16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 58 | 16.2k | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN7CTxUndo16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 58 | 16.2k | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN7CTxUndo16SerializationOpsI14BufferedWriterI8AutoFileEKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 58 | 16.2k | SERIALIZE_METHODS(CTxUndo, obj) { READWRITE(Using<VectorFormatter<TxInUndoFormatter>>(obj.vprevout)); } Line | Count | Source | 145 | 16.2k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
|
59 | | }; |
60 | | |
61 | | /** Undo information for a CBlock */ |
62 | | class CBlockUndo |
63 | | { |
64 | | public: |
65 | | std::vector<CTxUndo> vtxundo; // for all but the coinbase |
66 | | |
67 | 555k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 0 | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 0 | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 471k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
| SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
Unexecuted instantiation: _ZN10CBlockUndo16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_ Unexecuted instantiation: _ZN10CBlockUndo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_ _ZN10CBlockUndo16SerializationOpsI12HashVerifierI14BufferedReaderI8AutoFileEES_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 67 | 471k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 471k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN10CBlockUndo16SerializationOpsI12SizeComputerKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 67 | 28.0k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN10CBlockUndo16SerializationOpsI10HashWriterKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 67 | 28.0k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
_ZN10CBlockUndo16SerializationOpsI14BufferedWriterI8AutoFileEKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 67 | 28.0k | SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); } Line | Count | Source | 145 | 28.0k | #define READWRITE(...) (ser_action.SerReadWriteMany(s, __VA_ARGS__)) |
|
|
68 | | }; |
69 | | |
70 | | #endif // BITCOIN_UNDO_H |