From b56607a89ba112083f2b0a7b64ab18d66b26e2be Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 3 May 2020 18:41:01 +0000 Subject: [PATCH] Remove CCoinsViewCache::GetValueIn(...) --- src/bench/ccoins_caching.cpp | 2 -- src/coins.cpp | 12 ------------ src/coins.h | 10 ---------- src/primitives/transaction.h | 2 -- src/test/transaction_tests.cpp | 1 - 5 files changed, 27 deletions(-) diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp index d658976c3c..86f9a0bf67 100644 --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -47,8 +47,6 @@ static void CCoinsCaching(benchmark::State& state) while (state.KeepRunning()) { bool success = AreInputsStandard(tx_1, coins); assert(success); - CAmount value = coins.GetValueIn(tx_1); - assert(value == (50 + 21 + 22) * COIN); } ECC_Stop(); } diff --git a/src/coins.cpp b/src/coins.cpp index 6b4cb2aec7..7b76c13f98 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -233,18 +233,6 @@ unsigned int CCoinsViewCache::GetCacheSize() const { return cacheCoins.size(); } -CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const -{ - if (tx.IsCoinBase()) - return 0; - - CAmount nResult = 0; - for (unsigned int i = 0; i < tx.vin.size(); i++) - nResult += AccessCoin(tx.vin[i].prevout).out.nValue; - - return nResult; -} - bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const { if (!tx.IsCoinBase()) { diff --git a/src/coins.h b/src/coins.h index 2aed56c2bd..dcec741998 100644 --- a/src/coins.h +++ b/src/coins.h @@ -315,16 +315,6 @@ public: //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** - * Amount of bitcoins coming in to a transaction - * Note that lightweight clients may not know anything besides the hash of previous transactions, - * so may not be able to calculate this. - * - * @param[in] tx transaction for which we are checking input total - * @return Sum of value of all inputs (scriptSigs) - */ - CAmount GetValueIn(const CTransaction& tx) const; - //! Check whether all prevouts of the transaction are present in the UTXO set represented by this view bool HaveInputs(const CTransaction& tx) const; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 00ccbc32f9..58b3e8aedc 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -324,8 +324,6 @@ public: // Return sum of txouts. CAmount GetValueOut() const; - // GetValueIn() is a method on CCoinsViewCache, because - // inputs must be known to compute value in. /** * Get the total transaction size in bytes, including witness data. diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 9d0ae56c3f..ddbc68f8e2 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -305,7 +305,6 @@ BOOST_AUTO_TEST_CASE(test_Get) t1.vout[0].scriptPubKey << OP_1; BOOST_CHECK(AreInputsStandard(CTransaction(t1), coins)); - BOOST_CHECK_EQUAL(coins.GetValueIn(CTransaction(t1)), (50+21+22)*CENT); } static void CreateCreditAndSpend(const FillableSigningProvider& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)