LCOV - code coverage report
Current view: top level - src - undo.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 20 20 100.0 %
Date: 2021-06-29 14:35:33 Functions: 12 12 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 4 8 50.0 %

           Branch data     Line data    Source code
#       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                 :            : #include <version.h>
#      15                 :            : 
#      16                 :            : /** Formatter for undo information for a CTxIn
#      17                 :            :  *
#      18                 :            :  *  Contains the prevout's CTxOut being spent, and its metadata as well
#      19                 :            :  *  (coinbase or not, height). The serialization contains a dummy value of
#      20                 :            :  *  zero. This is compatible with older versions which expect to see
#      21                 :            :  *  the transaction version there.
#      22                 :            :  */
#      23                 :            : struct TxInUndoFormatter
#      24                 :            : {
#      25                 :            :     template<typename Stream>
#      26                 :     348764 :     void Ser(Stream &s, const Coin& txout) {
#      27                 :     348764 :         ::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase ));
#      28 [ +  - ][ +  - ]:     348764 :         if (txout.nHeight > 0) {
#                 [ +  - ]
#      29                 :            :             // Required to maintain compatibility with older undo format.
#      30                 :     348764 :             ::Serialize(s, (unsigned char)0);
#      31                 :     348764 :         }
#      32                 :     348764 :         ::Serialize(s, Using<TxOutCompression>(txout.out));
#      33                 :     348764 :     }
#      34                 :            : 
#      35                 :            :     template<typename Stream>
#      36                 :      19241 :     void Unser(Stream &s, Coin& txout) {
#      37                 :      19241 :         uint32_t nCode = 0;
#      38                 :      19241 :         ::Unserialize(s, VARINT(nCode));
#      39                 :      19241 :         txout.nHeight = nCode >> 1;
#      40                 :      19241 :         txout.fCoinBase = nCode & 1;
#      41         [ +  - ]:      19241 :         if (txout.nHeight > 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                 :      19241 :             unsigned int nVersionDummy;
#      46                 :      19241 :             ::Unserialize(s, VARINT(nVersionDummy));
#      47                 :      19241 :         }
#      48                 :      19241 :         ::Unserialize(s, Using<TxOutCompression>(txout.out));
#      49                 :      19241 :     }
#      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                 :     205476 :     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                 :     281372 :     SERIALIZE_METHODS(CBlockUndo, obj) { READWRITE(obj.vtxundo); }
#      69                 :            : };
#      70                 :            : 
#      71                 :            : #endif // BITCOIN_UNDO_H

Generated by: LCOV version 1.14