Remove unused members from CTxMemPoolEntry
What changed, and why it matters
This commit removes several unused internal accounting fields from Bitcoin Core's memory pool transaction entry class. It is a straightforward code cleanup: fields that tracked descendant and ancestor transaction sizes, fees, and counts are deleted, and the methods that updated them are left empty. There is no security-relevant change visible in the diff.
No security action required. Treat as normal refactoring. If reviewing the broader series, verify that any code still reading these removed fields has been updated in adjacent commits, but this patch itself is benign.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes private members m_count_with_descendants, nSizeWithDescendants, nModFeesWithDescendants, m_count_with_ancestors, nSizeWithAncestors, nModFeesWithAncestors, and nSigOpCostWithAncestors from CTxMemPoolEntry. It also removes their initialization in the constructor and their updates in UpdateModifiedFee, UpdateDescendantState, and UpdateAncestorState. The two Update* methods now do nothing. No callers of those methods are changed in this diff, and no logic that depends on the removed values is altered here.
Changed components
src/kernel/mempool_entry.hsrc/txmempool.cppInspect captured patch +1 / −35
diff --git a/src/kernel/mempool_entry.h b/src/kernel/mempool_entry.h
index 2e61f102..8be0a77e 100644
--- a/src/kernel/mempool_entry.h
+++ b/src/kernel/mempool_entry.h
@@ -88,21 +88,6 @@ private:
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
mutable LockPoints lockPoints; //!< Track the height and time at which tx was final
- // Information about descendants of this transaction that are in the
- // mempool; if we remove this transaction we must remove all of these
- // descendants as well.
- int64_t m_count_with_descendants{1}; //!< number of descendant transactions
- // Using int64_t instead of int32_t to avoid signed integer overflow issues.
- int64_t nSizeWithDescendants; //!< ... and size
- CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
-
- // Analogous statistics for ancestor transactions
- int64_t m_count_with_ancestors{1};
- // Using int64_t instead of int32_t to avoid signed integer overflow issues.
- int64_t nSizeWithAncestors;
- CAmount nModFeesWithAncestors;
- int64_t nSigOpCostWithAncestors;
-
public:
virtual ~CTxMemPoolEntry() = default;
CTxMemPoolEntry(TxGraph::Ref&& ref, const CTransactionRef& tx, CAmount fee,
@@ -120,12 +105,7 @@ public:
spendsCoinbase{spends_coinbase},
sigOpCost{sigops_cost},
m_modified_fee{nFee},
- lockPoints{lp},
- nSizeWithDescendants{GetTxSize()},
- nModFeesWithDescendants{nFee},
- nSizeWithAncestors{GetTxSize()},
- nModFeesWithAncestors{nFee},
- nSigOpCostWithAncestors{sigOpCost} {}
+ lockPoints{lp} {}
CTxMemPoolEntry& operator=(const CTxMemPoolEntry&) = delete;
CTxMemPoolEntry(CTxMemPoolEntry&&) = default;
@@ -155,8 +135,6 @@ public:
// Updates the modified fees with descendants/ancestors.
void UpdateModifiedFee(CAmount fee_diff)
{
- nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, fee_diff);
- nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, fee_diff);
m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff);
}
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 28a6418b..960296e2 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -361,22 +361,10 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
void CTxMemPoolEntry::UpdateDescendantState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount)
{
- nSizeWithDescendants += modifySize;
- assert(nSizeWithDescendants > 0);
- nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, modifyFee);
- m_count_with_descendants += modifyCount;
- assert(m_count_with_descendants > 0);
}
void CTxMemPoolEntry::UpdateAncestorState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
{
- nSizeWithAncestors += modifySize;
- assert(nSizeWithAncestors > 0);
- nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, modifyFee);
- m_count_with_ancestors += modifyCount;
- assert(m_count_with_ancestors > 0);
- nSigOpCostWithAncestors += modifySigOps;
- assert(int(nSigOpCostWithAncestors) >= 0);
}
//! Clamp option values and populate the error if options are not valid.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.