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

Method addUnchecked

src/txmempool.cpp:503–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
504{
505 // Add to memory pool without checking anything.
506 // Used by AcceptToMemoryPool(), which DOES do
507 // all the appropriate checks.
508 indexed_transaction_set::iterator newit = mapTx.insert(entry).first;
509
510 // Update transaction for any feeDelta created by PrioritiseTransaction
511 // TODO: refactor so that the fee delta is calculated before inserting
512 // into mapTx.
513 CAmount delta{0};
514 ApplyDelta(entry.GetTx().GetHash(), delta);
515 // The following call to UpdateModifiedFee assumes no previous fee modifications
516 Assume(entry.GetFee() == entry.GetModifiedFee());
517 if (delta) {
518 mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
519 }
520
521 // Update cachedInnerUsage to include contained transaction's usage.
522 // (When we update the entry for in-mempool parents, memory usage will be
523 // further updated.)
524 cachedInnerUsage += entry.DynamicMemoryUsage();
525
526 const CTransaction& tx = newit->GetTx();
527 std::set<uint256> setParentTransactions;
528 for (unsigned int i = 0; i < tx.vin.size(); i++) {
529 mapNextTx.insert(std::make_pair(&tx.vin[i].prevout, &tx));
530 setParentTransactions.insert(tx.vin[i].prevout.hash);
531 }
532 // Don't bother worrying about child transactions of this one.
533 // Normal case of a new transaction arriving is that there can't be any
534 // children, because such children would be orphans.
535 // An exception to that is if a transaction enters that used to be in a block.
536 // In that case, our disconnect block logic will call UpdateTransactionsFromBlock
537 // to clean up the mess we're leaving here.
538
539 // Update ancestors with information about this tx
540 for (const auto& pit : GetIterSet(setParentTransactions)) {
541 UpdateParent(newit, pit, true);
542 }
543 UpdateAncestorsOf(true, newit, setAncestors);
544 UpdateEntryForAncestors(newit, setAncestors);
545
546 nTransactionsUpdated++;
547 totalTxSize += entry.GetTxSize();
548 m_total_fee += entry.GetFee();
549 if (minerPolicyEstimator) {
550 minerPolicyEstimator->processTransaction(entry, validFeeEstimate);
551 }
552
553 vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
554 newit->vTxHashesIdx = vTxHashes.size() - 1;
555}
556
557void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
558{

Callers 10

FinalizeMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
TestPackageSelectionMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80
mempool_stress.cppFile · 0.80
rpc_mempool.cppFile · 0.80

Calls 11

GetTxMethod · 0.80
GetFeeMethod · 0.80
UpdateModifiedFeeMethod · 0.80
processTransactionMethod · 0.80
emplace_backMethod · 0.80
insertMethod · 0.45
GetHashMethod · 0.45
GetModifiedFeeMethod · 0.45
DynamicMemoryUsageMethod · 0.45
sizeMethod · 0.45
GetTxSizeMethod · 0.45

Tested by 6

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
TestPackageSelectionMethod · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
FUZZ_TARGET_INITFunction · 0.64