Skip to content

Commit a70beaf

Browse files
committed
validation: when adding txs due to a block reorg, allow immediate relay
1 parent 1e9684f commit a70beaf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/validation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,10 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
834834
}
835835
}
836836

837-
entry.reset(new CTxMemPoolEntry(ptx, ws.m_base_fees, nAcceptTime, m_active_chainstate.m_chain.Height(), m_pool.GetSequence(),
837+
// Set entry_sequence to 0 when bypass_limits is used; this allows txs from a block
838+
// reorg to be marked earlier than any child txs that were already in the mempool.
839+
const uint64_t entry_sequence = bypass_limits ? 0 : m_pool.GetSequence();
840+
entry.reset(new CTxMemPoolEntry(ptx, ws.m_base_fees, nAcceptTime, m_active_chainstate.m_chain.Height(), entry_sequence,
838841
fSpendsCoinbase, nSigOpsCost, lock_points.value()));
839842
ws.m_vsize = entry->GetTxSize();
840843

src/validation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ struct PackageMempoolAcceptResult
239239
* @param[in] tx The transaction to submit for mempool acceptance.
240240
* @param[in] accept_time The timestamp for adding the transaction to the mempool.
241241
* It is also used to determine when the entry expires.
242-
* @param[in] bypass_limits When true, don't enforce mempool fee and capacity limits.
242+
* @param[in] bypass_limits When true, don't enforce mempool fee and capacity limits,
243+
* and set entry_sequence to zero.
243244
* @param[in] test_accept When true, run validation checks but don't submit to mempool.
244245
*
245246
* @returns a MempoolAcceptResult indicating whether the transaction was accepted/rejected with reason.

0 commit comments

Comments
 (0)