LCOV - code coverage report
Current view: top level - src - core_memusage.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 28 0.0 %
Date: 2023-10-05 12:38:51 Functions: 0 8 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2015-2018 The Bitcoin Core developers
       2                 :            : // Distributed under the MIT software license, see the accompanying
       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :            : 
       5                 :            : #ifndef BITCOIN_CORE_MEMUSAGE_H
       6                 :            : #define BITCOIN_CORE_MEMUSAGE_H
       7                 :            : 
       8                 :            : #include <primitives/transaction.h>
       9                 :            : #include <primitives/block.h>
      10                 :            : #include <memusage.h>
      11                 :            : 
      12                 :          0 : static inline size_t RecursiveDynamicUsage(const CScript& script) {
      13                 :          0 :     return memusage::DynamicUsage(script);
      14                 :            : }
      15                 :            : 
      16                 :          0 : static inline size_t RecursiveDynamicUsage(const COutPoint& out) {
      17                 :          0 :     return 0;
      18                 :            : }
      19                 :            : 
      20                 :          0 : static inline size_t RecursiveDynamicUsage(const CTxIn& in) {
      21                 :          0 :     size_t mem = RecursiveDynamicUsage(in.scriptSig) + RecursiveDynamicUsage(in.prevout) + memusage::DynamicUsage(in.scriptWitness.stack);
      22         [ #  # ]:          0 :     for (std::vector<std::vector<unsigned char> >::const_iterator it = in.scriptWitness.stack.begin(); it != in.scriptWitness.stack.end(); it++) {
      23                 :          0 :          mem += memusage::DynamicUsage(*it);
      24                 :          0 :     }
      25                 :          0 :     return mem;
      26                 :            : }
      27                 :            : 
      28                 :          0 : static inline size_t RecursiveDynamicUsage(const CTxOut& out) {
      29                 :          0 :     return RecursiveDynamicUsage(out.scriptPubKey);
      30                 :            : }
      31                 :            : 
      32                 :          0 : static inline size_t RecursiveDynamicUsage(const CTransaction& tx) {
      33                 :          0 :     size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout);
      34         [ #  # ]:          0 :     for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) {
      35                 :          0 :         mem += RecursiveDynamicUsage(*it);
      36                 :          0 :     }
      37         [ #  # ]:          0 :     for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) {
      38                 :          0 :         mem += RecursiveDynamicUsage(*it);
      39                 :          0 :     }
      40                 :          0 :     return mem;
      41                 :            : }
      42                 :            : 
      43                 :            : static inline size_t RecursiveDynamicUsage(const CMutableTransaction& tx) {
      44                 :            :     size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout);
      45                 :            :     for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) {
      46                 :            :         mem += RecursiveDynamicUsage(*it);
      47                 :            :     }
      48                 :            :     for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) {
      49                 :            :         mem += RecursiveDynamicUsage(*it);
      50                 :            :     }
      51                 :            :     return mem;
      52                 :            : }
      53                 :            : 
      54                 :          0 : static inline size_t RecursiveDynamicUsage(const CBlock& block) {
      55                 :          0 :     size_t mem = memusage::DynamicUsage(block.vtx);
      56         [ #  # ]:          0 :     for (const auto& tx : block.vtx) {
      57                 :          0 :         mem += memusage::DynamicUsage(tx) + RecursiveDynamicUsage(*tx);
      58                 :            :     }
      59                 :          0 :     return mem;
      60                 :            : }
      61                 :            : 
      62                 :            : static inline size_t RecursiveDynamicUsage(const CBlockLocator& locator) {
      63                 :            :     return memusage::DynamicUsage(locator.vHave);
      64                 :            : }
      65                 :            : 
      66                 :            : template<typename X>
      67                 :          0 : static inline size_t RecursiveDynamicUsage(const std::shared_ptr<X>& p) {
      68         [ #  # ]:          0 :     return p ? memusage::DynamicUsage(p) + RecursiveDynamicUsage(*p) : 0;
      69                 :            : }
      70                 :            : 
      71                 :            : #endif // BITCOIN_CORE_MEMUSAGE_H

Generated by: LCOV version 1.14