| 96 | } |
| 97 | |
| 98 | bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) { |
| 99 | CCoinsMap::iterator it = FetchCoin(outpoint); |
| 100 | if (it == cacheCoins.end()) return false; |
| 101 | cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage(); |
| 102 | if (moveout) { |
| 103 | *moveout = std::move(it->second.coin); |
| 104 | } |
| 105 | if (it->second.flags & CCoinsCacheEntry::FRESH) { |
| 106 | cacheCoins.erase(it); |
| 107 | } else { |
| 108 | it->second.flags |= CCoinsCacheEntry::DIRTY; |
| 109 | it->second.coin.Clear(); |
| 110 | } |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | static const Coin coinEmpty; |
| 115 | |