mempool: eliminate accessors to mempool entry ancestor/descendant cached state
This commit is contained in:
1 parent
b9a2039f51
commit
ff3b398d12
2 files changed
+1
-33
No files matched your search
@@ -166,17 +166,8 @@ public:
|
|||||||
lockPoints = lp;
|
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; }
|
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 Parents& GetMemPoolParentsConst() const { return m_parents; }
|
||||||
const Children& GetMemPoolChildrenConst() const { return m_children; }
|
const Children& GetMemPoolChildrenConst() const { return m_children; }
|
||||||
Parents& GetMemPoolParents() const { return m_parents; }
|
Parents& GetMemPoolParents() const { return m_parents; }
|
||||||
|
|||||||
+1
-24
@@ -720,40 +720,17 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
|||||||
};
|
};
|
||||||
assert(setParentCheck.size() == it->GetMemPoolParentsConst().size());
|
assert(setParentCheck.size() == it->GetMemPoolParentsConst().size());
|
||||||
assert(std::equal(setParentCheck.begin(), setParentCheck.end(), it->GetMemPoolParentsConst().begin(), comp));
|
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
|
// Check children against mapNextTx
|
||||||
CTxMemPoolEntry::Children setChildrenCheck;
|
CTxMemPoolEntry::Children setChildrenCheck;
|
||||||
auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0));
|
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) {
|
for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
|
||||||
txiter childit = iter->second;
|
txiter childit = iter->second;
|
||||||
assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
|
assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
|
||||||
if (setChildrenCheck.insert(*childit).second) {
|
setChildrenCheck.insert(*childit);
|
||||||
child_sizes += childit->GetTxSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assert(setChildrenCheck.size() == it->GetMemPoolChildrenConst().size());
|
assert(setChildrenCheck.size() == it->GetMemPoolChildrenConst().size());
|
||||||
assert(std::equal(setChildrenCheck.begin(), setChildrenCheck.end(), it->GetMemPoolChildrenConst().begin(), comp));
|
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
|
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
|
||||||
CAmount txfee = 0;
|
CAmount txfee = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user