diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-11-06 01:32:04 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2016-06-22 15:42:59 +0200 |
commit | 7030d9eb47254499bba14f1c00abc6bf493efd91 (patch) | |
tree | 95055978907c7418c1b96728ff09413781b9c0b7 /src/core_memusage.h | |
parent | ecacfd98e657c5819a1bcb1da93b25d3ad4e5045 (diff) |
BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo.
Contains fixup by Nicolas Dorier.
Contains cleanup of CInv::GetCommand by Alex Morcos
Diffstat (limited to 'src/core_memusage.h')
-rw-r--r-- | src/core_memusage.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/core_memusage.h b/src/core_memusage.h index 450537d059..dd86f805fe 100644 --- a/src/core_memusage.h +++ b/src/core_memusage.h @@ -25,8 +25,28 @@ static inline size_t RecursiveDynamicUsage(const CTxOut& out) { return RecursiveDynamicUsage(out.scriptPubKey); } +static inline size_t RecursiveDynamicUsage(const CScriptWitness& scriptWit) { + size_t mem = memusage::DynamicUsage(scriptWit.stack); + for (std::vector<std::vector<unsigned char> >::const_iterator it = scriptWit.stack.begin(); it != scriptWit.stack.end(); it++) { + mem += memusage::DynamicUsage(*it); + } + return mem; +} + +static inline size_t RecursiveDynamicUsage(const CTxinWitness& txinwit) { + return RecursiveDynamicUsage(txinwit.scriptWitness); +} + +static inline size_t RecursiveDynamicUsage(const CTxWitness& txwit) { + size_t mem = memusage::DynamicUsage(txwit.vtxinwit); + for (std::vector<CTxinWitness>::const_iterator it = txwit.vtxinwit.begin(); it != txwit.vtxinwit.end(); it++) { + mem += RecursiveDynamicUsage(*it); + } + return mem; +} + static inline size_t RecursiveDynamicUsage(const CTransaction& tx) { - size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout); + size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout) + RecursiveDynamicUsage(tx.wit); for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) { mem += RecursiveDynamicUsage(*it); } @@ -37,7 +57,7 @@ static inline size_t RecursiveDynamicUsage(const CTransaction& tx) { } static inline size_t RecursiveDynamicUsage(const CMutableTransaction& tx) { - size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout); + size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout) + RecursiveDynamicUsage(tx.wit); for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) { mem += RecursiveDynamicUsage(*it); } |