| 356 | } |
| 357 | |
| 358 | void CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate) |
| 359 | { |
| 360 | NotifyEntryAdded(entry.GetSharedTx()); |
| 361 | // Add to memory pool without checking anything. |
| 362 | // Used by AcceptToMemoryPool(), which DOES do |
| 363 | // all the appropriate checks. |
| 364 | indexed_transaction_set::iterator newit = mapTx.insert(entry).first; |
| 365 | mapLinks.insert(make_pair(newit, TxLinks())); |
| 366 | |
| 367 | // Update transaction for any feeDelta created by PrioritiseTransaction |
| 368 | // TODO: refactor so that the fee delta is calculated before inserting |
| 369 | // into mapTx. |
| 370 | std::map<uint256, CAmount>::const_iterator pos = mapDeltas.find(hash); |
| 371 | if (pos != mapDeltas.end()) { |
| 372 | const CAmount &delta = pos->second; |
| 373 | if (delta) { |
| 374 | mapTx.modify(newit, update_fee_delta(delta)); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | // Update cachedInnerUsage to include contained transaction's usage. |
| 379 | // (When we update the entry for in-mempool parents, memory usage will be |
| 380 | // further updated.) |
| 381 | cachedInnerUsage += entry.DynamicMemoryUsage(); |
| 382 | |
| 383 | const CTransaction& tx = newit->GetTx(); |
| 384 | std::set<uint256> setParentTransactions; |
| 385 | for (unsigned int i = 0; i < tx.vin.size(); i++) { |
| 386 | mapNextTx.insert(std::make_pair(&tx.vin[i].prevout, &tx)); |
| 387 | setParentTransactions.insert(tx.vin[i].prevout.hash); |
| 388 | } |
| 389 | // Don't bother worrying about child transactions of this one. |
| 390 | // Normal case of a new transaction arriving is that there can't be any |
| 391 | // children, because such children would be orphans. |
| 392 | // An exception to that is if a transaction enters that used to be in a block. |
| 393 | // In that case, our disconnect block logic will call UpdateTransactionsFromBlock |
| 394 | // to clean up the mess we're leaving here. |
| 395 | |
| 396 | // Update ancestors with information about this tx |
| 397 | for (const uint256 &phash : setParentTransactions) { |
| 398 | txiter pit = mapTx.find(phash); |
| 399 | if (pit != mapTx.end()) { |
| 400 | UpdateParent(newit, pit, true); |
| 401 | } |
| 402 | } |
| 403 | UpdateAncestorsOf(true, newit, setAncestors); |
| 404 | UpdateEntryForAncestors(newit, setAncestors); |
| 405 | |
| 406 | nTransactionsUpdated++; |
| 407 | totalTxSize += entry.GetTxSize(); |
| 408 | if (minerPolicyEstimator) {minerPolicyEstimator->processTransaction(entry, validFeeEstimate);} |
| 409 | |
| 410 | vTxHashes.emplace_back(tx.GetWitnessHash(), newit); |
| 411 | newit->vTxHashesIdx = vTxHashes.size() - 1; |
| 412 | } |
| 413 | |
| 414 | void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) |
| 415 | { |