aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2021-10-04 12:58:50 +0100
committerglozow <gloriajzhao@gmail.com>2021-10-04 15:00:28 +0100
commited6115f1eae0eb4669601106a9aaff078a2f3a74 (patch)
tree9e59db60bd18cc5f8c6eb56ba44eab880a1b77f2 /src/txmempool.cpp
parent9e8d7ad5d9cc4b013826daead9cee09aad539401 (diff)
downloadbitcoin-ed6115f1eae0eb4669601106a9aaff078a2f3a74.tar.xz
[mempool] simplify some check() logic
No transaction in the mempool should ever be a coinbase. Since mempoolDuplicate's backend is the chainstate coins view, it should always contain the coins available.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index c1abe24af7..f65fb24f19 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -704,14 +704,12 @@ void CTxMemPool::check(CChainState& active_chainstate) const
if (it2 != mapTx.end()) {
const CTransaction& tx2 = it2->GetTx();
assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
- // We are iterating through the mempool entries sorted in order by ancestor count.
- // All parents must have been checked before their children and their coins added to
- // the mempoolDuplicate coins cache.
- assert(mempoolDuplicate.HaveCoin(txin.prevout));
setParentCheck.insert(*it2);
- } else {
- assert(active_coins_tip.HaveCoin(txin.prevout));
}
+ // We are iterating through the mempool entries sorted in order by ancestor count.
+ // All parents must have been checked before their children and their coins added to
+ // the mempoolDuplicate coins cache.
+ assert(mempoolDuplicate.HaveCoin(txin.prevout));
// Check whether its inputs are marked in mapNextTx.
auto it3 = mapNextTx.find(txin.prevout);
assert(it3 != mapNextTx.end());
@@ -766,8 +764,8 @@ void CTxMemPool::check(CChainState& active_chainstate) const
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
CAmount txfee = 0;
- bool fCheckResult = tx.IsCoinBase() || Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee);
- assert(fCheckResult);
+ assert(!tx.IsCoinBase());
+ assert(Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee));
for (const auto& input: tx.vin) mempoolDuplicate.SpendCoin(input.prevout);
AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
}