MCPcopy Create free account
hub / github.com/ElementsProject/elements / CalculateMemPoolAncestors

Method CalculateMemPoolAncestors

src/txmempool.cpp:320–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
321 setEntries &setAncestors,
322 uint64_t limitAncestorCount,
323 uint64_t limitAncestorSize,
324 uint64_t limitDescendantCount,
325 uint64_t limitDescendantSize,
326 std::string &errString,
327 bool fSearchForParents /* = true */) const
328{
329 CTxMemPoolEntry::Parents staged_ancestors;
330 const CTransaction &tx = entry.GetTx();
331
332 if (fSearchForParents) {
333 // Get parents of this transaction that are in the mempool
334 // GetMemPoolParents() is only valid for entries in the mempool, so we
335 // iterate mapTx to find parents.
336 for (unsigned int i = 0; i < tx.vin.size(); i++) {
337 std::optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
338 if (piter) {
339 staged_ancestors.insert(**piter);
340 if (staged_ancestors.size() + 1 > limitAncestorCount) {
341 errString = strprintf("too many unconfirmed parents [limit: %u]", limitAncestorCount);
342 return false;
343 }
344 }
345 }
346 } else {
347 // If we're not searching for parents, we require this to already be an
348 // entry in the mempool and use the entry's cached parents.
349 txiter it = mapTx.iterator_to(entry);
350 staged_ancestors = it->GetMemPoolParentsConst();
351 }
352
353 return CalculateAncestorsAndCheckLimits(entry.GetTxSize(), /* entry_count */ 1,
354 setAncestors, staged_ancestors,
355 limitAncestorCount, limitAncestorSize,
356 limitDescendantCount, limitDescendantSize, errString);
357}
358
359void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors)
360{

Callers 7

PreChecksMethod · 0.80
SubmitPackageMethod · 0.80
IsRBFOptInFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
getmempoolancestorsFunction · 0.80
addPackageTxsMethod · 0.80
checkChainLimitsMethod · 0.80

Calls 4

GetTxMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
GetTxSizeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64