| 501 | } |
| 502 | |
| 503 | void 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 | |
| 557 | void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) |
| 558 | { |