| 137 | } |
| 138 | |
| 139 | bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) { |
| 140 | CCoinsMap::iterator it = FetchCoin(outpoint); |
| 141 | if (it == cacheCoins.end()) return false; |
| 142 | cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage(); |
| 143 | TRACE5(utxocache, spent, |
| 144 | outpoint.hash.data(), |
| 145 | (uint32_t)outpoint.n, |
| 146 | (uint32_t)it->second.coin.nHeight, |
| 147 | it->second.coin.out.nValue.IsExplicit() ? (int64_t)it->second.coin.out.nValue.GetAmount() : 0, |
| 148 | (bool)it->second.coin.IsCoinBase()); |
| 149 | if (moveout) { |
| 150 | *moveout = std::move(it->second.coin); |
| 151 | } |
| 152 | if (it->second.flags & CCoinsCacheEntry::FRESH) { |
| 153 | cacheCoins.erase(it); |
| 154 | } else { |
| 155 | it->second.flags |= CCoinsCacheEntry::DIRTY; |
| 156 | it->second.coin.Clear(); |
| 157 | } |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | // ELEMENTS: |
| 162 | // Because g_con_elementsmode is only set after the moment coinEmpty is initialized, |