Skip to content

Commit ed6115f

Browse files
committed
[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.
1 parent 9e8d7ad commit ed6115f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/txmempool.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,14 +704,12 @@ void CTxMemPool::check(CChainState& active_chainstate) const
704704
if (it2 != mapTx.end()) {
705705
const CTransaction& tx2 = it2->GetTx();
706706
assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
707-
// We are iterating through the mempool entries sorted in order by ancestor count.
708-
// All parents must have been checked before their children and their coins added to
709-
// the mempoolDuplicate coins cache.
710-
assert(mempoolDuplicate.HaveCoin(txin.prevout));
711707
setParentCheck.insert(*it2);
712-
} else {
713-
assert(active_coins_tip.HaveCoin(txin.prevout));
714708
}
709+
// We are iterating through the mempool entries sorted in order by ancestor count.
710+
// All parents must have been checked before their children and their coins added to
711+
// the mempoolDuplicate coins cache.
712+
assert(mempoolDuplicate.HaveCoin(txin.prevout));
715713
// Check whether its inputs are marked in mapNextTx.
716714
auto it3 = mapNextTx.find(txin.prevout);
717715
assert(it3 != mapNextTx.end());
@@ -766,8 +764,8 @@ void CTxMemPool::check(CChainState& active_chainstate) const
766764

767765
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
768766
CAmount txfee = 0;
769-
bool fCheckResult = tx.IsCoinBase() || Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee);
770-
assert(fCheckResult);
767+
assert(!tx.IsCoinBase());
768+
assert(Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee));
771769
for (const auto& input: tx.vin) mempoolDuplicate.SpendCoin(input.prevout);
772770
AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
773771
}

0 commit comments

Comments
 (0)