| 126 | } |
| 127 | |
| 128 | void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool check_for_overwrite) { |
| 129 | bool fCoinbase = tx.IsCoinBase(); |
| 130 | const uint256& txid = tx.GetHash(); |
| 131 | for (size_t i = 0; i < tx.vout.size(); ++i) { |
| 132 | bool overwrite = check_for_overwrite ? cache.HaveCoin(COutPoint(txid, i)) : fCoinbase; |
| 133 | // Coinbase transactions can always be overwritten, in order to correctly |
| 134 | // deal with the pre-BIP30 occurrences of duplicate coinbase transactions. |
| 135 | cache.AddCoin(COutPoint(txid, i), Coin(tx.vout[i], nHeight, fCoinbase), overwrite); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) { |
| 140 | CCoinsMap::iterator it = FetchCoin(outpoint); |