mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
[validation] return correct result when already-in-mempool tx gets evicted
Bug fix: a transaction may be in the mempool when package evaluation begins (so it is added to results_final with MEMPOOL_ENTRY or DIFFERENT_WITNESS), but get evicted due to another transaction submission.
This commit is contained in:
parent
9698b81828
commit
d227b7234c
1 changed files with 11 additions and 1 deletions
|
@ -1525,9 +1525,19 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
|
|||
Assume(results_final.count(wtxid) == 0);
|
||||
results_final.emplace(wtxid, multi_submission_result.m_tx_results.at(wtxid));
|
||||
} else if (const auto it{results_final.find(wtxid)}; it != results_final.end()) {
|
||||
// Already-in-mempool transaction.
|
||||
// Already-in-mempool transaction. Check to see if it's still there, as it could have
|
||||
// been evicted when LimitMempoolSize() was called.
|
||||
Assume(it->second.m_result_type != MempoolAcceptResult::ResultType::INVALID);
|
||||
Assume(individual_results_nonfinal.count(wtxid) == 0);
|
||||
// Query by txid to include the same-txid-different-witness ones.
|
||||
if (!m_pool.exists(GenTxid::Txid(tx->GetHash()))) {
|
||||
package_state_final.Invalid(PackageValidationResult::PCKG_TX, "transaction failed");
|
||||
TxValidationState mempool_full_state;
|
||||
mempool_full_state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool full");
|
||||
// Replace the previous result.
|
||||
results_final.erase(wtxid);
|
||||
results_final.emplace(wtxid, MempoolAcceptResult::Failure(mempool_full_state));
|
||||
}
|
||||
} else if (const auto it{individual_results_nonfinal.find(wtxid)}; it != individual_results_nonfinal.end()) {
|
||||
Assume(it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
|
||||
// Interesting result from previous processing.
|
||||
|
|
Loading…
Add table
Reference in a new issue