Skip to content

Commit 284a1d3

Browse files
committed
Move prioritisation into changeset
1 parent 446b08b commit 284a1d3

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/test/rbf_tests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ BOOST_FIXTURE_TEST_CASE(improves_feerate, TestChain100Setup)
362362
const CAmount normal_fee{CENT/10};
363363

364364
// low feerate parent with normal feerate child
365-
const auto tx1 = make_tx(/*inputs=*/ {m_coinbase_txns[0]}, /*output_values=*/ {10 * COIN});
365+
const auto tx1 = make_tx(/*inputs=*/ {m_coinbase_txns[0], m_coinbase_txns[1]}, /*output_values=*/ {10 * COIN});
366366
AddToMempool(pool, entry.Fee(low_fee).FromTx(tx1));
367367
const auto tx2 = make_tx(/*inputs=*/ {tx1}, /*output_values=*/ {995 * CENT});
368368
AddToMempool(pool, entry.Fee(normal_fee).FromTx(tx2));
@@ -374,6 +374,9 @@ BOOST_FIXTURE_TEST_CASE(improves_feerate, TestChain100Setup)
374374
const auto tx2_fee = entry2->GetModifiedFee();
375375
const auto tx2_size = entry2->GetTxSize();
376376

377+
// conflicting transactions
378+
const auto tx1_conflict = make_tx(/*inputs=*/ {m_coinbase_txns[0], m_coinbase_txns[2]}, /*output_values=*/ {10 * COIN});
379+
377380
// Now test ImprovesFeerateDiagram with various levels of "package rbf" feerates
378381

379382
// It doesn't improve itself

src/txmempool.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,6 @@ void CTxMemPool::addNewTransaction(CTxMemPool::txiter newit, CTxMemPool::setEntr
478478
{
479479
const CTxMemPoolEntry& entry = *newit;
480480

481-
// Update transaction for any feeDelta created by PrioritiseTransaction
482-
// TODO: move this into the changeset instead.
483-
CAmount delta{0};
484-
ApplyDelta(newit->GetTx().GetHash(), delta);
485-
// The following call to UpdateModifiedFee assumes no previous fee modifications
486-
Assume(newit->GetFee() == newit->GetModifiedFee());
487-
if (delta) {
488-
mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
489-
}
490-
491481
// Update cachedInnerUsage to include contained transaction's usage.
492482
// (When we update the entry for in-mempool parents, memory usage will be
493483
// further updated.)
@@ -1411,8 +1401,13 @@ util::Result<std::pair<std::vector<FeeFrac>, std::vector<FeeFrac>>> CTxMemPool::
14111401

14121402
CTxMemPool::ChangeSet::TxHandle CTxMemPool::ChangeSet::StageAddition(const CTransactionRef& tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
14131403
{
1404+
LOCK(m_pool->cs);
14141405
Assume(m_to_add.find(tx->GetHash()) == m_to_add.end());
14151406
auto newit = m_to_add.emplace(tx, fee, time, entry_height, entry_sequence, spends_coinbase, sigops_cost, lp).first;
1407+
CAmount delta{0};
1408+
m_pool->ApplyDelta(tx->GetHash(), delta);
1409+
if (delta) m_to_add.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
1410+
14161411
m_entry_vec.push_back(newit);
14171412
return newit;
14181413
}

src/validation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,6 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
889889

890890
int64_t nSigOpsCost = GetTransactionSigOpCost(tx, m_view, STANDARD_SCRIPT_VERIFY_FLAGS);
891891

892-
// ws.m_modified_fees includes any fee deltas from PrioritiseTransaction
893-
ws.m_modified_fees = ws.m_base_fees;
894-
m_pool.ApplyDelta(hash, ws.m_modified_fees);
895-
896892
// Keep track of transactions that spend a coinbase, which we re-scan
897893
// during reorgs to ensure COINBASE_MATURITY is still met.
898894
bool fSpendsCoinbase = false;
@@ -912,6 +908,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
912908
}
913909
ws.m_tx_handle = m_subpackage.m_changeset->StageAddition(ptx, ws.m_base_fees, nAcceptTime, m_active_chainstate.m_chain.Height(), entry_sequence, fSpendsCoinbase, nSigOpsCost, lock_points.value());
914910

911+
// ws.m_modified_fees includes any fee deltas from PrioritiseTransaction
912+
ws.m_modified_fees = ws.m_tx_handle->GetModifiedFee();
913+
915914
ws.m_vsize = ws.m_tx_handle->GetTxSize();
916915

917916
// Enforces 0-fee for dust transactions, no incentive to be mined alone

0 commit comments

Comments
 (0)