diff options
author | glozow <gloriajzhao@gmail.com> | 2021-10-04 13:01:38 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2021-10-04 15:00:28 +0100 |
commit | 9e8d7ad5d9cc4b013826daead9cee09aad539401 (patch) | |
tree | c10b2f86152cd8639f4c1af45b7e741c16cb0459 /src/txmempool.cpp | |
parent | 09d18916afb0ecae90700d4befd9d5dc52767970 (diff) | |
download | bitcoin-9e8d7ad5d9cc4b013826daead9cee09aad539401.tar.xz |
[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/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 4 |
1 files changed, 3 insertions, 1 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(); |