diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -385,7 +385,7 @@ // Call UpdateCoins on the top cache CTxUndo undo; - UpdateCoins(CTransaction(tx), *(stack.back()), undo, height); + UpdateCoins(*(stack.back()), CTransaction(tx), undo, height); // Update the utxo set for future spends utxoset.insert(outpoint); diff --git a/src/test/undo_tests.cpp b/src/test/undo_tests.cpp --- a/src/test/undo_tests.cpp +++ b/src/test/undo_tests.cpp @@ -17,13 +17,13 @@ CBlockUndo &blockundo, const CChainParams &chainparams, uint32_t nHeight) { auto &coinbaseTx = *block.vtx[0]; - UpdateCoins(coinbaseTx, view, nHeight); + UpdateCoins(view, coinbaseTx, nHeight); for (size_t i = 1; i < block.vtx.size(); i++) { auto &tx = *block.vtx[1]; blockundo.vtxundo.push_back(CTxUndo()); - UpdateCoins(tx, view, blockundo.vtxundo.back(), nHeight); + UpdateCoins(view, tx, blockundo.vtxundo.back(), nHeight); } view.SetBestBlock(block.GetHash()); diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -793,7 +793,7 @@ Consensus::CheckTxInputs( tx, state, mempoolDuplicate, nSpendHeight); assert(fCheckResult); - UpdateCoins(tx, mempoolDuplicate, 1000000); + UpdateCoins(mempoolDuplicate, tx, 1000000); } } @@ -812,7 +812,7 @@ Consensus::CheckTxInputs(entry->GetTx(), state, mempoolDuplicate, nSpendHeight); assert(fCheckResult); - UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000); + UpdateCoins(mempoolDuplicate, entry->GetTx(), 1000000); stepsSinceLastRemove = 0; } } diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -517,9 +517,9 @@ std::vector *pvChecks = nullptr); /** Apply the effects of this transaction on the UTXO set represented by view */ -void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight); -void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, - CTxUndo &txundo, int nHeight); +void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight); +void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, + int nHeight); /** Transaction validation functions */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1455,26 +1455,26 @@ } } -void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, - CTxUndo &txundo, int nHeight) { +void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, + int nHeight) { // Mark inputs spent. if (!tx.IsCoinBase()) { txundo.vprevout.reserve(tx.vin.size()); for (const CTxIn &txin : tx.vin) { txundo.vprevout.emplace_back(); bool is_spent = - inputs.SpendCoin(txin.prevout, &txundo.vprevout.back()); + view.SpendCoin(txin.prevout, &txundo.vprevout.back()); assert(is_spent); } } // Add outputs. - AddCoins(inputs, tx, nHeight); + AddCoins(view, tx, nHeight); } -void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight) { +void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight) { CTxUndo txundo; - UpdateCoins(tx, inputs, txundo, nHeight); + UpdateCoins(view, tx, txundo, nHeight); } bool CScriptCheck::operator()() { @@ -2247,7 +2247,7 @@ if (i > 0) { blockundo.vtxundo.push_back(CTxUndo()); } - UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), + UpdateCoins(view, tx, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); vPos.push_back(std::make_pair(tx.GetId(), pos)); @@ -4644,7 +4644,7 @@ * Apply the effects of a block on the utxo cache, ignoring that it may already * have been applied. */ -static bool RollforwardBlock(const CBlockIndex *pindex, CCoinsViewCache &inputs, +static bool RollforwardBlock(const CBlockIndex *pindex, CCoinsViewCache &view, const Config &config) { // TODO: merge with ConnectBlock CBlock block; @@ -4656,12 +4656,12 @@ for (const CTransactionRef &tx : block.vtx) { if (!tx->IsCoinBase()) { for (const CTxIn &txin : tx->vin) { - inputs.SpendCoin(txin.prevout); + view.SpendCoin(txin.prevout); } } // Pass check = true as every addition may be an overwrite. - AddCoins(inputs, *tx, pindex->nHeight, true); + AddCoins(view, *tx, pindex->nHeight, true); } return true;