Changeset View
Changeset View
Standalone View
Standalone View
src/coins.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin coin, | ||||
} | } | ||||
it->second.coin = std::move(coin); | it->second.coin = std::move(coin); | ||||
it->second.flags |= | it->second.flags |= | ||||
CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0); | CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0); | ||||
cachedCoinsUsage += it->second.coin.DynamicMemoryUsage(); | cachedCoinsUsage += it->second.coin.DynamicMemoryUsage(); | ||||
} | } | ||||
void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, | void AddCoins(CCoinsViewCache &cache, const CTransaction &tx, int nHeight, | ||||
bool check) { | bool check_for_overwrite) { | ||||
bool fCoinbase = tx.IsCoinBase(); | bool fCoinbase = tx.IsCoinBase(); | ||||
const TxId txid = tx.GetId(); | const TxId txid = tx.GetId(); | ||||
for (size_t i = 0; i < tx.vout.size(); ++i) { | for (size_t i = 0; i < tx.vout.size(); ++i) { | ||||
const COutPoint outpoint(txid, i); | const COutPoint outpoint(txid, i); | ||||
bool overwrite = check ? cache.HaveCoin(outpoint) : fCoinbase; | bool overwrite = | ||||
// Always set the possible_overwrite flag to AddCoin for coinbase txn, | check_for_overwrite ? cache.HaveCoin(outpoint) : fCoinbase; | ||||
// Coinbase transactions can always be overwritten, | |||||
// in order to correctly deal with the pre-BIP30 occurrences of | // in order to correctly deal with the pre-BIP30 occurrences of | ||||
// duplicate coinbase transactions. | // duplicate coinbase transactions. | ||||
cache.AddCoin(outpoint, Coin(tx.vout[i], nHeight, fCoinbase), | cache.AddCoin(outpoint, Coin(tx.vout[i], nHeight, fCoinbase), | ||||
overwrite); | overwrite); | ||||
} | } | ||||
} | } | ||||
bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin *moveout) { | bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin *moveout) { | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |