| 1099 | CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { } |
| 1100 | |
| 1101 | bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const { |
| 1102 | // Check to see if the inputs are made available by another tx in the package. |
| 1103 | // These Coins would not be available in the underlying CoinsView. |
| 1104 | if (auto it = m_temp_added.find(outpoint); it != m_temp_added.end()) { |
| 1105 | coin = it->second; |
| 1106 | return true; |
| 1107 | } |
| 1108 | |
| 1109 | // If an entry in the mempool exists, always return that one, as it's guaranteed to never |
| 1110 | // conflict with the underlying cache, and it cannot have pruned entries (as it contains full) |
| 1111 | // transactions. First checking the underlying cache risks returning a pruned entry instead. |
| 1112 | CTransactionRef ptx = mempool.get(outpoint.hash); |
| 1113 | if (ptx) { |
| 1114 | if (outpoint.n < ptx->vout.size()) { |
| 1115 | coin = Coin(ptx->vout[outpoint.n], MEMPOOL_HEIGHT, false); |
| 1116 | return true; |
| 1117 | } else { |
| 1118 | return false; |
| 1119 | } |
| 1120 | } |
| 1121 | return base->GetCoin(outpoint, coin); |
| 1122 | } |
| 1123 | |
| 1124 | void CCoinsViewMemPool::PackageAddTransaction(const CTransactionRef& tx) |
| 1125 | { |