Skip to content

Commit a70ff3c

Browse files
committed
set nNonce to Null in CoinsView
1 parent eda3fbe commit a70ff3c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/coins.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ static inline CCoinsMapKey native_key(const COutPoint& outpoint) {
5151

5252
CCoinsMap::iterator CCoinsViewCache::FetchCoin(const COutPoint &outpoint) const {
5353
CCoinsMap::iterator it = cacheCoins.find(native_key(outpoint));
54-
if (it != cacheCoins.end())
54+
if (it != cacheCoins.end()) {
55+
assert(it->second.coin.out.nNonce.IsNull());
5556
return it;
57+
}
5658
Coin tmp;
5759
if (!base->GetCoin(outpoint, tmp))
5860
return cacheCoins.end();
@@ -72,6 +74,7 @@ bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const {
7274
CCoinsMap::const_iterator it = FetchCoin(outpoint);
7375
if (it != cacheCoins.end()) {
7476
coin = it->second.coin;
77+
assert(coin.out.nNonce.IsNull());
7578
return !coin.IsSpent();
7679
}
7780
return false;
@@ -119,7 +122,9 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool
119122
bool overwrite = check_for_overwrite ? cache.HaveCoin(COutPoint(txid, i)) : fCoinbase;
120123
// Coinbase transactions can always be overwritten, in order to correctly
121124
// deal with the pre-BIP30 occurrences of duplicate coinbase transactions.
122-
cache.AddCoin(COutPoint(txid, i), Coin(tx.vout[i], nHeight, fCoinbase), overwrite);
125+
Coin new_coin(tx.vout[i], nHeight, fCoinbase);
126+
new_coin.out.nNonce.SetNull();
127+
cache.AddCoin(COutPoint(txid, i), std::move(new_coin), overwrite);
123128
}
124129
}
125130

0 commit comments

Comments
 (0)