| 209 | } |
| 210 | |
| 211 | void CCoinsViewCache::SetPeginSpent(const std::pair<uint256, COutPoint> &outpoint, bool fSpent) { |
| 212 | assert(!outpoint.second.hash.IsNull()); |
| 213 | assert(!outpoint.first.IsNull()); |
| 214 | |
| 215 | CCoinsMap::iterator it = cacheCoins.find(outpoint); |
| 216 | |
| 217 | bool hadSpent; |
| 218 | if (it == cacheCoins.end()) |
| 219 | hadSpent = base->IsPeginSpent(outpoint); |
| 220 | else |
| 221 | hadSpent = it->second.peginSpent; |
| 222 | |
| 223 | // If we aren't changing spentness, don't do anything at all |
| 224 | if (hadSpent == fSpent) |
| 225 | return; |
| 226 | |
| 227 | if (it == cacheCoins.end()) { |
| 228 | bool inserted; |
| 229 | std::tie(it, inserted) = cacheCoins.emplace(std::piecewise_construct, |
| 230 | std::forward_as_tuple(outpoint), std::tuple<>()); |
| 231 | if (!hadSpent) |
| 232 | it->second.flags = CCoinsCacheEntry::FRESH; |
| 233 | } |
| 234 | it->second.peginSpent = fSpent; |
| 235 | it->second.flags |= CCoinsCacheEntry::PEGIN | CCoinsCacheEntry::DIRTY; |
| 236 | } |
| 237 | |
| 238 | // END ELEMENTS |
| 239 | // |