Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

core_memusage.h
Go to the documentation of this file.
1 // Copyright (c) 2015 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 
9 #include <primitives/block.h>
10 #include <memusage.h>
11 
12 static inline size_t RecursiveDynamicUsage(const CScript& script) {
13  return memusage::DynamicUsage(script);
14 }
15 
16 static inline size_t RecursiveDynamicUsage(const COutPoint& out) {
17  return 0;
18 }
19 
20 static inline size_t RecursiveDynamicUsage(const CTxIn& in) {
22 }
23 
24 static inline size_t RecursiveDynamicUsage(const CTxOut& out) {
26 }
27 
28 static inline size_t RecursiveDynamicUsage(const CTransaction& tx) {
30  for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) {
31  mem += RecursiveDynamicUsage(*it);
32  }
33  for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) {
34  mem += RecursiveDynamicUsage(*it);
35  }
36  return mem;
37 }
38 
39 static inline size_t RecursiveDynamicUsage(const CMutableTransaction& tx) {
41  for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) {
42  mem += RecursiveDynamicUsage(*it);
43  }
44  for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) {
45  mem += RecursiveDynamicUsage(*it);
46  }
47  return mem;
48 }
49 
50 static inline size_t RecursiveDynamicUsage(const CBlock& block) {
51  size_t mem = memusage::DynamicUsage(block.vtx);
52  for (const auto& tx : block.vtx) {
54  }
55  return mem;
56 }
57 
58 static inline size_t RecursiveDynamicUsage(const CBlockLocator& locator) {
59  return memusage::DynamicUsage(locator.vHave);
60 }
61 
62 template<typename X>
63 static inline size_t RecursiveDynamicUsage(const std::shared_ptr<X>& p) {
64  return p ? memusage::DynamicUsage(p) + RecursiveDynamicUsage(*p) : 0;
65 }
66 
67 #endif // BITCOIN_CORE_MEMUSAGE_H
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:127
CScript scriptPubKey
Definition: transaction.h:148
Definition: block.h:72
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
Definition: memusage.h:27
std::vector< CTxIn > vin
Definition: transaction.h:293
const std::vector< CTxIn > vin
Definition: transaction.h:215
An input of a transaction.
Definition: transaction.h:70
const std::vector< CTxOut > vout
Definition: transaction.h:216
An output of a transaction.
Definition: transaction.h:144
std::vector< uint256 > vHave
Definition: block.h:129
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
std::vector< CTxOut > vout
Definition: transaction.h:294
CScript scriptSig
Definition: transaction.h:74
std::vector< CTransactionRef > vtx
Definition: block.h:76
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:389
static size_t RecursiveDynamicUsage(const CScript &script)
Definition: core_memusage.h:12
A mutable version of CTransaction.
Definition: transaction.h:291
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
COutPoint prevout
Definition: transaction.h:73
Released under the MIT license