-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate core memory usage computation in core_memusage.h
- Loading branch information
Showing
11 changed files
with
76 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2015 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_CORE_MEMUSAGE_H | ||
#define BITCOIN_CORE_MEMUSAGE_H | ||
|
||
#include "primitives/transaction.h" | ||
#include "primitives/block.h" | ||
#include "memusage.h" | ||
|
||
static inline size_t RecursiveDynamicUsage(const CScript& script) { | ||
return memusage::DynamicUsage(*static_cast<const std::vector<unsigned char>*>(&script)); | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const COutPoint& out) { | ||
return 0; | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CTxIn& in) { | ||
return RecursiveDynamicUsage(in.scriptSig) + RecursiveDynamicUsage(in.prevout); | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CTxOut& out) { | ||
return RecursiveDynamicUsage(out.scriptPubKey); | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CTransaction& tx) { | ||
size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout); | ||
for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) { | ||
mem += RecursiveDynamicUsage(*it); | ||
} | ||
for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) { | ||
mem += RecursiveDynamicUsage(*it); | ||
} | ||
return mem; | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CMutableTransaction& tx) { | ||
size_t mem = memusage::DynamicUsage(tx.vin) + memusage::DynamicUsage(tx.vout); | ||
for (std::vector<CTxIn>::const_iterator it = tx.vin.begin(); it != tx.vin.end(); it++) { | ||
mem += RecursiveDynamicUsage(*it); | ||
} | ||
for (std::vector<CTxOut>::const_iterator it = tx.vout.begin(); it != tx.vout.end(); it++) { | ||
mem += RecursiveDynamicUsage(*it); | ||
} | ||
return mem; | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CBlock& block) { | ||
size_t mem = memusage::DynamicUsage(block.vtx) + memusage::DynamicUsage(block.vMerkleTree); | ||
for (std::vector<CTransaction>::const_iterator it = block.vtx.begin(); it != block.vtx.end(); it++) { | ||
mem += RecursiveDynamicUsage(*it); | ||
} | ||
return mem; | ||
} | ||
|
||
static inline size_t RecursiveDynamicUsage(const CBlockLocator& locator) { | ||
return memusage::DynamicUsage(locator.vHave); | ||
} | ||
|
||
#endif // BITCOIN_CORE_MEMUSAGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters