diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -65,15 +65,12 @@ CMutableTransaction t1; t1.vin.resize(3); - t1.vin[0].prevout.hash = dummyTransactions[0].GetId(); - t1.vin[0].prevout.n = 1; + t1.vin[0].prevout = COutPoint(dummyTransactions[0].GetId(), 1); t1.vin[0].scriptSig << std::vector(65, 0); - t1.vin[1].prevout.hash = dummyTransactions[1].GetId(); - t1.vin[1].prevout.n = 0; + t1.vin[1].prevout = COutPoint(dummyTransactions[1].GetId(), 0); t1.vin[1].scriptSig << std::vector(65, 0) << std::vector(33, 4); - t1.vin[2].prevout.hash = dummyTransactions[1].GetId(); - t1.vin[2].prevout.n = 1; + t1.vin[2].prevout = COutPoint(dummyTransactions[1].GetId(), 1); t1.vin[2].scriptSig << std::vector(65, 0) << std::vector(33, 4); t1.vout.resize(2); diff --git a/src/coins.h b/src/coins.h --- a/src/coins.h +++ b/src/coins.h @@ -86,7 +86,7 @@ * implementation. */ size_t operator()(const COutPoint &outpoint) const { - return SipHashUint256Extra(k0, k1, outpoint.hash, outpoint.n); + return SipHashUint256Extra(k0, k1, outpoint.GetTxId(), outpoint.GetN()); } }; diff --git a/src/coins.cpp b/src/coins.cpp --- a/src/coins.cpp +++ b/src/coins.cpp @@ -332,13 +332,11 @@ MAX_TX_SIZE / ::GetSerializeSize(CTxOut(), SER_NETWORK, PROTOCOL_VERSION); const Coin &AccessByTxid(const CCoinsViewCache &view, const uint256 &txid) { - COutPoint iter(txid, 0); - while (iter.n < MAX_OUTPUTS_PER_TX) { - const Coin &alternate = view.AccessCoin(iter); + for (uint32_t n = 0; n < MAX_OUTPUTS_PER_TX; n++) { + const Coin &alternate = view.AccessCoin(COutPoint(txid, n)); if (!alternate.IsSpent()) { return alternate; } - ++iter.n; } return coinEmpty; 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 @@ -357,8 +357,7 @@ prevout = utxod->first; // Construct the tx to spend the coins of prevouthash - tx.vin[0].prevout = prevout; - tx.vin[0].prevout.n = 0; + tx.vin[0].prevout = COutPoint(prevout.GetTxId(), 0); assert(!CTransaction(tx).IsCoinBase()); }