| 978 | CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView* baseIn, const CTxMemPool& mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { } |
| 979 | |
| 980 | bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, CCoins &coin) const { |
| 981 | // If an entry in the mempool exists, always return that one, as it's guaranteed to never |
| 982 | // conflict with the underlying cache, and it cannot have pruned entries (as it contains full) |
| 983 | // transactions. First checking the underlying cache risks returning a pruned entry instead. |
| 984 | CTransactionRef ptx = mempool.get(outpoint.hash); |
| 985 | if (ptx) { |
| 986 | if (outpoint.n < ptx->vout.size()) { |
| 987 | coin = CCoins(*ptx, MEMPOOL_HEIGHT); |
| 988 | return true; |
| 989 | } else { |
| 990 | return false; |
| 991 | } |
| 992 | } |
| 993 | return (base->GetCoins(outpoint.hash, coin) /*&& !coin.IsSpent()*/); |
| 994 | } |
| 995 | |
| 996 | bool CCoinsViewMemPool::HaveCoin(const COutPoint &outpoint) const { |
| 997 | return mempool.exists(outpoint) || base->HaveCoins(outpoint.hash); |