mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Add RecursiveDynamicUsage overload for std::shared_ptr
This simplifies a few usage expressions.
This commit is contained in:
parent
71f1903353
commit
c1235e3f2d
@ -63,4 +63,9 @@ static inline size_t RecursiveDynamicUsage(const CBlockLocator& locator) {
|
||||
return memusage::DynamicUsage(locator.vHave);
|
||||
}
|
||||
|
||||
template<typename X>
|
||||
static inline size_t RecursiveDynamicUsage(const std::shared_ptr<X>& p) {
|
||||
return p ? memusage::DynamicUsage(p) + RecursiveDynamicUsage(*p) : 0;
|
||||
}
|
||||
|
||||
#endif // BITCOIN_CORE_MEMUSAGE_H
|
||||
|
@ -23,7 +23,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFe
|
||||
spendsCoinbase(_spendsCoinbase), sigOpCost(_sigOpsCost), lockPoints(lp)
|
||||
{
|
||||
nTxWeight = GetTransactionWeight(*tx);
|
||||
nUsageSize = RecursiveDynamicUsage(*tx) + memusage::DynamicUsage(tx);
|
||||
nUsageSize = RecursiveDynamicUsage(tx);
|
||||
|
||||
nCountWithDescendants = 1;
|
||||
nSizeWithDescendants = GetTxSize();
|
||||
|
@ -740,7 +740,7 @@ struct DisconnectedBlockTransactions {
|
||||
void addTransaction(const CTransactionRef& tx)
|
||||
{
|
||||
queuedTx.insert(tx);
|
||||
cachedInnerUsage += RecursiveDynamicUsage(*tx) + memusage::DynamicUsage(tx);
|
||||
cachedInnerUsage += RecursiveDynamicUsage(tx);
|
||||
}
|
||||
|
||||
// Remove entries based on txid_index, and update memory usage.
|
||||
@ -753,7 +753,7 @@ struct DisconnectedBlockTransactions {
|
||||
for (auto const &tx : vtx) {
|
||||
auto it = queuedTx.find(tx->GetHash());
|
||||
if (it != queuedTx.end()) {
|
||||
cachedInnerUsage -= RecursiveDynamicUsage(**it) + memusage::DynamicUsage(*it);
|
||||
cachedInnerUsage -= RecursiveDynamicUsage(*it);
|
||||
queuedTx.erase(it);
|
||||
}
|
||||
}
|
||||
@ -762,7 +762,7 @@ struct DisconnectedBlockTransactions {
|
||||
// Remove an entry by insertion_order index, and update memory usage.
|
||||
void removeEntry(indexed_disconnected_transactions::index<insertion_order>::type::iterator entry)
|
||||
{
|
||||
cachedInnerUsage -= RecursiveDynamicUsage(**entry) + memusage::DynamicUsage(*entry);
|
||||
cachedInnerUsage -= RecursiveDynamicUsage(*entry);
|
||||
queuedTx.get<insertion_order>().erase(entry);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user