mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
mempool: eliminate accessors to mempool entry ancestor/descendant cached state
This commit is contained in:
@@ -166,17 +166,8 @@ public:
|
||||
lockPoints = lp;
|
||||
}
|
||||
|
||||
uint64_t GetCountWithDescendants() const { return m_count_with_descendants; }
|
||||
int64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
|
||||
CAmount GetModFeesWithDescendants() const { return nModFeesWithDescendants; }
|
||||
|
||||
bool GetSpendsCoinbase() const { return spendsCoinbase; }
|
||||
|
||||
uint64_t GetCountWithAncestors() const { return m_count_with_ancestors; }
|
||||
int64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
||||
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
||||
int64_t GetSigOpCostWithAncestors() const { return nSigOpCostWithAncestors; }
|
||||
|
||||
const Parents& GetMemPoolParentsConst() const { return m_parents; }
|
||||
const Children& GetMemPoolChildrenConst() const { return m_children; }
|
||||
Parents& GetMemPoolParents() const { return m_parents; }
|
||||
|
||||
@@ -720,40 +720,17 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
||||
};
|
||||
assert(setParentCheck.size() == it->GetMemPoolParentsConst().size());
|
||||
assert(std::equal(setParentCheck.begin(), setParentCheck.end(), it->GetMemPoolParentsConst().begin(), comp));
|
||||
// Verify ancestor state is correct.
|
||||
auto ancestors{AssumeCalculateMemPoolAncestors(__func__, *it, Limits::NoLimits())};
|
||||
uint64_t nCountCheck = ancestors.size() + 1;
|
||||
int32_t nSizeCheck = it->GetTxSize();
|
||||
CAmount nFeesCheck = it->GetModifiedFee();
|
||||
int64_t nSigOpCheck = it->GetSigOpCost();
|
||||
|
||||
for (txiter ancestorIt : ancestors) {
|
||||
nSizeCheck += ancestorIt->GetTxSize();
|
||||
nFeesCheck += ancestorIt->GetModifiedFee();
|
||||
nSigOpCheck += ancestorIt->GetSigOpCost();
|
||||
}
|
||||
|
||||
assert(it->GetCountWithAncestors() == nCountCheck);
|
||||
assert(it->GetSizeWithAncestors() == nSizeCheck);
|
||||
assert(it->GetSigOpCostWithAncestors() == nSigOpCheck);
|
||||
assert(it->GetModFeesWithAncestors() == nFeesCheck);
|
||||
|
||||
// Check children against mapNextTx
|
||||
CTxMemPoolEntry::Children setChildrenCheck;
|
||||
auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0));
|
||||
int32_t child_sizes{0};
|
||||
for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
|
||||
txiter childit = iter->second;
|
||||
assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
|
||||
if (setChildrenCheck.insert(*childit).second) {
|
||||
child_sizes += childit->GetTxSize();
|
||||
}
|
||||
setChildrenCheck.insert(*childit);
|
||||
}
|
||||
assert(setChildrenCheck.size() == it->GetMemPoolChildrenConst().size());
|
||||
assert(std::equal(setChildrenCheck.begin(), setChildrenCheck.end(), it->GetMemPoolChildrenConst().begin(), comp));
|
||||
// Also check to make sure size is greater than sum with immediate children.
|
||||
// just a sanity check, not definitive that this calc is correct...
|
||||
assert(it->GetSizeWithDescendants() >= child_sizes + it->GetTxSize());
|
||||
|
||||
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
|
||||
CAmount txfee = 0;
|
||||
|
||||
Reference in New Issue
Block a user