b4a3da2642
These are technically static libs, but not in any way shared libs. They are used solely only by this repo and really only by the hub. Most important, no header files are installed and basically none of the normal rules for reusable libraries are applied to these files.
78 lines
2.7 KiB
C++
78 lines
2.7 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2015 The Bitcoin Core developers
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef FLOWEE_CORE_MEMUSAGE_H
|
|
#define FLOWEE_CORE_MEMUSAGE_H
|
|
|
|
#include <primitives/transaction.h>
|
|
#include <primitives/MutableBlock.h>
|
|
#include "memusage.h"
|
|
#include "blocklocator.h"
|
|
|
|
static inline size_t RecursiveDynamicUsage(const CScript& script) {
|
|
return memusage::DynamicUsage(*static_cast<const CScriptBase*>(&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 MutableBlock& block) {
|
|
size_t mem = memusage::DynamicUsage(block.vtx);
|
|
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
|