Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool were somehow broken and returning the wrong scriptPubKeys
| 549 | // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool |
| 550 | // were somehow broken and returning the wrong scriptPubKeys |
| 551 | static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& view, const CTxMemPool& pool, |
| 552 | unsigned int flags, bool cacheSigStore, PrecomputedTransactionData& txdata) { |
| 553 | AssertLockHeld(cs_main); |
| 554 | |
| 555 | // pool.cs should be locked already, but go ahead and re-take the lock here |
| 556 | // to enforce that mempool doesn't change between when we check the view |
| 557 | // and when we actually call through to CheckInputs |
| 558 | LOCK(pool.cs); |
| 559 | |
| 560 | assert(!tx.IsCoinBase()); |
| 561 | for (const CTxIn& txin : tx.vin) { |
| 562 | const Coin& coin = view.AccessCoin(txin.prevout); |
| 563 | |
| 564 | // At this point we haven't actually checked if the coins are all |
| 565 | // available (or shouldn't assume we have, since CheckInputs does). |
| 566 | // So we just return failure if the inputs are not available here, |
| 567 | // and then only have to check equivalence for available inputs. |
| 568 | if (coin.IsSpent()) return false; |
| 569 | |
| 570 | const CTransactionRef& txFrom = pool.get(txin.prevout.hash); |
| 571 | if (txFrom) { |
| 572 | assert(txFrom->GetHash() == txin.prevout.hash); |
| 573 | assert(txFrom->vout.size() > txin.prevout.n); |
| 574 | assert(txFrom->vout[txin.prevout.n] == coin.out); |
| 575 | } else { |
| 576 | const Coin& coinFromDisk = pcoinsTip->AccessCoin(txin.prevout); |
| 577 | assert(!coinFromDisk.IsSpent()); |
| 578 | assert(coinFromDisk.out == coin.out); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | return CheckInputs(tx, state, view, true, flags, cacheSigStore, true, txdata); |
| 583 | } |
| 584 | |
| 585 | static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx, |
| 586 | bool* pfMissingInputs, int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced, |
no test coverage detected