mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
[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.
This commit is contained in:
parent
9e8d7ad5d9
commit
ed6115f1ea
1 changed files with 6 additions and 8 deletions
|
@ -704,14 +704,12 @@ void CTxMemPool::check(CChainState& active_chainstate) const
|
||||||
if (it2 != mapTx.end()) {
|
if (it2 != mapTx.end()) {
|
||||||
const CTransaction& tx2 = it2->GetTx();
|
const CTransaction& tx2 = it2->GetTx();
|
||||||
assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
|
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);
|
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.
|
// Check whether its inputs are marked in mapNextTx.
|
||||||
auto it3 = mapNextTx.find(txin.prevout);
|
auto it3 = mapNextTx.find(txin.prevout);
|
||||||
assert(it3 != mapNextTx.end());
|
assert(it3 != mapNextTx.end());
|
||||||
|
@ -766,8 +764,8 @@ void CTxMemPool::check(CChainState& active_chainstate) const
|
||||||
|
|
||||||
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
|
TxValidationState dummy_state; // Not used. CheckTxInputs() should always pass
|
||||||
CAmount txfee = 0;
|
CAmount txfee = 0;
|
||||||
bool fCheckResult = tx.IsCoinBase() || Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee);
|
assert(!tx.IsCoinBase());
|
||||||
assert(fCheckResult);
|
assert(Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee));
|
||||||
for (const auto& input: tx.vin) mempoolDuplicate.SpendCoin(input.prevout);
|
for (const auto& input: tx.vin) mempoolDuplicate.SpendCoin(input.prevout);
|
||||||
AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
|
AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue