Skip to content

Commit 90a002e

Browse files
committed
Merge #10558: Address nits from per-utxo change
21d4afa Comment clarifications in coins.cpp (Alex Morcos) 3c8a9ae Add belt-and-suspenders in DisconnectBlock (Alex Morcos) Tree-SHA512: d83e12ed71674faaaaebc03ffa1e2276984c35a29db419268ac9e14a45b33ccab716e3606dff8cfe1dcee4bec6e4794d2ca90341f10d5684be80e3fee61addf8
2 parents 30c2130 + 21d4afa commit 90a002e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/coins.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ class CCoinsViewCache : public CCoinsViewBacked
306306
void AddCoins(CCoinsViewCache& cache, const CTransaction& tx, int nHeight, bool check = false);
307307

308308
//! Utility function to find any unspent output with a given txid.
309+
// This function can be quite expensive because in the event of a transaction
310+
// which is not found in the cache, it can cause up to MAX_OUTPUTS_PER_BLOCK
311+
// lookups to database, so it should be used with care.
309312
const Coin& AccessByTxid(const CCoinsViewCache& cache, const uint256& txid);
310313

311314
#endif // BITCOIN_COINS_H

src/validation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,7 @@ static DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex*
13661366
for (int i = block.vtx.size() - 1; i >= 0; i--) {
13671367
const CTransaction &tx = *(block.vtx[i]);
13681368
uint256 hash = tx.GetHash();
1369+
bool is_coinbase = tx.IsCoinBase();
13691370

13701371
// Check that all outputs are available and match the outputs in the block itself
13711372
// exactly.
@@ -1374,7 +1375,7 @@ static DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex*
13741375
COutPoint out(hash, o);
13751376
Coin coin;
13761377
bool is_spent = view.SpendCoin(out, &coin);
1377-
if (!is_spent || tx.vout[o] != coin.out) {
1378+
if (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.fCoinBase) {
13781379
fClean = false; // transaction output mismatch
13791380
}
13801381
}

0 commit comments

Comments
 (0)