aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-10-04 13:01:38 +0100
committerglozow <gloriajzhao@gmail.com>2021-10-04 15:00:28 +0100
commit9e8d7ad5d9cc4b013826daead9cee09aad539401 (patch)
treec10b2f86152cd8639f4c1af45b7e741c16cb0459 /src
parent09d18916afb0ecae90700d4befd9d5dc52767970 (diff)
[validation/mempool] use Spend/AddCoin instead of UpdateCoins
UpdateCoins is an unnecessary dependency on validation. All we need to do is add and remove coins to check inputs. We don't need the extra logic for checking coinbases and handling TxUndos. Also remove the wrapper function in validation.h which constructs a throwaway TxUndo object before calling UpdateCoins because it is now unused.
Diffstat (limited to 'src')
-rw-r--r--src/txmempool.cpp4
-rw-r--r--src/validation.cpp6
-rw-r--r--src/validation.h3
3 files changed, 3 insertions, 10 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 40e142dc47..c1abe24af7 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -5,6 +5,7 @@
#include <txmempool.h>
+#include <coins.h>
#include <consensus/consensus.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
@@ -767,7 +768,8 @@ void CTxMemPool::check(CChainState& active_chainstate) const
CAmount txfee = 0;
bool fCheckResult = tx.IsCoinBase() || Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee);
assert(fCheckResult);
- UpdateCoins(tx, mempoolDuplicate, std::numeric_limits<int>::max());
+ for (const auto& input: tx.vin) mempoolDuplicate.SpendCoin(input.prevout);
+ AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
}
for (auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) {
uint256 hash = it->second->GetHash();
diff --git a/src/validation.cpp b/src/validation.cpp
index 4504d2ca0a..863502e0d7 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1240,12 +1240,6 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund
AddCoins(inputs, tx, nHeight);
}
-void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight)
-{
- CTxUndo txundo;
- UpdateCoins(tx, inputs, txundo, nHeight);
-}
-
bool CScriptCheck::operator()() {
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
const CScriptWitness *witness = &ptxTo->vin[nIn].scriptWitness;
diff --git a/src/validation.h b/src/validation.h
index b2282828ce..caa0832dd3 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -229,9 +229,6 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx
const Package& txns, bool test_accept)
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
-/** Apply the effects of this transaction on the UTXO set represented by view */
-void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
-
/** Transaction validation functions */
/**