Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
core_memusage.h
Go to the documentation of this file.
1// Copyright (c) 2015-2016 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 <memusage.h>
9#include <primitives/block.h>
11
12static inline size_t RecursiveDynamicUsage(const CScript &script) {
13 return memusage::DynamicUsage(*static_cast<const CScriptBase *>(&script));
14}
15
16static inline size_t RecursiveDynamicUsage(const COutPoint &out) {
17 return 0;
18}
19
20static inline size_t RecursiveDynamicUsage(const CTxIn &in) {
21 return RecursiveDynamicUsage(in.scriptSig) +
23}
24
25static inline size_t RecursiveDynamicUsage(const CTxOut &out) {
27}
28
29static inline size_t RecursiveDynamicUsage(const CTransaction &tx) {
30 size_t mem =
32 for (std::vector<CTxIn>::const_iterator it = tx.vin.begin();
33 it != tx.vin.end(); it++) {
34 mem += RecursiveDynamicUsage(*it);
35 }
36 for (std::vector<CTxOut>::const_iterator it = tx.vout.begin();
37 it != tx.vout.end(); it++) {
38 mem += RecursiveDynamicUsage(*it);
39 }
40 return mem;
41}
42
43static inline size_t RecursiveDynamicUsage(const CMutableTransaction &tx) {
44 size_t mem =
46 for (std::vector<CTxIn>::const_iterator it = tx.vin.begin();
47 it != tx.vin.end(); it++) {
48 mem += RecursiveDynamicUsage(*it);
49 }
50 for (std::vector<CTxOut>::const_iterator it = tx.vout.begin();
51 it != tx.vout.end(); it++) {
52 mem += RecursiveDynamicUsage(*it);
53 }
54 return mem;
55}
56
57template <typename X>
58static inline size_t RecursiveDynamicUsage(const std::shared_ptr<X> &p) {
60}
61
62#endif // BITCOIN_CORE_MEMUSAGE_H
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< CTxIn > vin
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition transaction.h:20
Serialized script, used inside transaction inputs and outputs.
Definition script.h:424
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const std::vector< CTxIn > vin
An input of a transaction.
Definition transaction.h:59
An output of a transaction.
CScript scriptPubKey
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition prevector.h:38
static size_t RecursiveDynamicUsage(const CScript &script)
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
Definition memusage.h:27
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85