@@ -603,13 +603,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
603
603
604
604
// Alias what we need out of ws
605
605
TxValidationState& state = ws.m_state ;
606
- std::set<uint256>& setConflicts = ws.m_conflicts ;
607
- CTxMemPool::setEntries& allConflicting = ws.m_all_conflicting ;
608
- CTxMemPool::setEntries& setAncestors = ws.m_ancestors ;
609
606
std::unique_ptr<CTxMemPoolEntry>& entry = ws.m_entry ;
610
- CAmount& nModifiedFees = ws.m_modified_fees ;
611
- CAmount& nConflictingFees = ws.m_conflicting_fees ;
612
- size_t & nConflictingSize = ws.m_conflicting_size ;
613
607
614
608
if (!CheckTransaction (tx, state)) {
615
609
return false ; // state filled in by CheckTransaction
@@ -655,7 +649,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
655
649
// Transaction conflicts with a mempool tx, but we're not allowing replacements.
656
650
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " bip125-replacement-disallowed" );
657
651
}
658
- if (!setConflicts .count (ptxConflicting->GetHash ()))
652
+ if (!ws. m_conflicts .count (ptxConflicting->GetHash ()))
659
653
{
660
654
// Transactions that don't explicitly signal replaceability are
661
655
// *not* replaceable with the current logic, even if one of their
@@ -668,7 +662,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
668
662
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " txn-mempool-conflict" );
669
663
}
670
664
671
- setConflicts .insert (ptxConflicting->GetHash ());
665
+ ws. m_conflicts .insert (ptxConflicting->GetHash ());
672
666
}
673
667
}
674
668
}
@@ -732,9 +726,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
732
726
733
727
int64_t nSigOpsCost = GetTransactionSigOpCost (tx, m_view, STANDARD_SCRIPT_VERIFY_FLAGS);
734
728
735
- // nModifiedFees includes any fee deltas from PrioritiseTransaction
736
- nModifiedFees = ws.m_base_fees ;
737
- m_pool.ApplyDelta (hash, nModifiedFees );
729
+ // ws.m_modified_fees includes any fee deltas from PrioritiseTransaction
730
+ ws. m_modified_fees = ws.m_base_fees ;
731
+ m_pool.ApplyDelta (hash, ws. m_modified_fees );
738
732
739
733
// Keep track of transactions that spend a coinbase, which we re-scan
740
734
// during reorgs to ensure COINBASE_MATURITY is still met.
@@ -757,11 +751,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
757
751
758
752
// No transactions are allowed below minRelayTxFee except from disconnected
759
753
// blocks
760
- if (!bypass_limits && !CheckFeeRate (ws.m_vsize , nModifiedFees , state)) return false ;
754
+ if (!bypass_limits && !CheckFeeRate (ws.m_vsize , ws. m_modified_fees , state)) return false ;
761
755
762
- ws.m_iters_conflicting = m_pool.GetIterSet (setConflicts );
756
+ ws.m_iters_conflicting = m_pool.GetIterSet (ws. m_conflicts );
763
757
// Calculate in-mempool ancestors, up to a limit.
764
- if (setConflicts .size () == 1 ) {
758
+ if (ws. m_conflicts .size () == 1 ) {
765
759
// In general, when we receive an RBF transaction with mempool conflicts, we want to know whether we
766
760
// would meet the chain limits after the conflicts have been removed. However, there isn't a practical
767
761
// way to do this short of calculating the ancestor and descendant sets with an overlay cache of
@@ -797,8 +791,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
797
791
}
798
792
799
793
std::string errString;
800
- if (!m_pool.CalculateMemPoolAncestors (*entry, setAncestors , m_limit_ancestors, m_limit_ancestor_size, m_limit_descendants, m_limit_descendant_size, errString)) {
801
- setAncestors .clear ();
794
+ if (!m_pool.CalculateMemPoolAncestors (*entry, ws. m_ancestors , m_limit_ancestors, m_limit_ancestor_size, m_limit_descendants, m_limit_descendant_size, errString)) {
795
+ ws. m_ancestors .clear ();
802
796
// If CalculateMemPoolAncestors fails second time, we want the original error string.
803
797
std::string dummy_err_string;
804
798
// Contracting/payment channels CPFP carve-out:
@@ -813,24 +807,24 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
813
807
// outputs - one for each counterparty. For more info on the uses for
814
808
// this, see https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2018-November/016518.html
815
809
if (ws.m_vsize > EXTRA_DESCENDANT_TX_SIZE_LIMIT ||
816
- !m_pool.CalculateMemPoolAncestors (*entry, setAncestors , 2 , m_limit_ancestor_size, m_limit_descendants + 1 , m_limit_descendant_size + EXTRA_DESCENDANT_TX_SIZE_LIMIT, dummy_err_string)) {
810
+ !m_pool.CalculateMemPoolAncestors (*entry, ws. m_ancestors , 2 , m_limit_ancestor_size, m_limit_descendants + 1 , m_limit_descendant_size + EXTRA_DESCENDANT_TX_SIZE_LIMIT, dummy_err_string)) {
817
811
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " too-long-mempool-chain" , errString);
818
812
}
819
813
}
820
814
821
815
// A transaction that spends outputs that would be replaced by it is invalid. Now
822
816
// that we have the set of all ancestors we can detect this
823
- // pathological case by making sure setConflicts and setAncestors don't
817
+ // pathological case by making sure ws.m_conflicts and ws.m_ancestors don't
824
818
// intersect.
825
- if (const auto err_string{EntriesAndTxidsDisjoint (setAncestors, setConflicts , hash)}) {
819
+ if (const auto err_string{EntriesAndTxidsDisjoint (ws. m_ancestors , ws. m_conflicts , hash)}) {
826
820
// We classify this as a consensus error because a transaction depending on something it
827
821
// conflicts with would be inconsistent.
828
822
return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-txns-spends-conflicting-tx" , *err_string);
829
823
}
830
824
831
- m_rbf = !setConflicts .empty ();
825
+ m_rbf = !ws. m_conflicts .empty ();
832
826
if (m_rbf) {
833
- CFeeRate newFeeRate (nModifiedFees , ws.m_vsize );
827
+ CFeeRate newFeeRate (ws. m_modified_fees , ws.m_vsize );
834
828
// It's possible that the replacement pays more fees than its direct conflicts but not more
835
829
// than all conflicts (i.e. the direct conflicts have high-fee descendants). However, if the
836
830
// replacement doesn't pay more fees than its direct conflicts, then we can be sure it's not
@@ -842,7 +836,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
842
836
}
843
837
844
838
// Calculate all conflicting entries and enforce BIP125 Rule #5.
845
- if (const auto err_string{GetEntriesForConflicts (tx, m_pool, ws.m_iters_conflicting , allConflicting )}) {
839
+ if (const auto err_string{GetEntriesForConflicts (tx, m_pool, ws.m_iters_conflicting , ws. m_all_conflicting )}) {
846
840
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY,
847
841
" too many potential replacements" , *err_string);
848
842
}
@@ -854,11 +848,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
854
848
855
849
// Check if it's economically rational to mine this transaction rather than the ones it
856
850
// replaces and pays for its own relay fees. Enforce BIP125 Rules #3 and #4.
857
- for (CTxMemPool::txiter it : allConflicting ) {
858
- nConflictingFees += it->GetModifiedFee ();
859
- nConflictingSize += it->GetTxSize ();
851
+ for (CTxMemPool::txiter it : ws. m_all_conflicting ) {
852
+ ws. m_conflicting_fees += it->GetModifiedFee ();
853
+ ws. m_conflicting_size += it->GetTxSize ();
860
854
}
861
- if (const auto err_string{PaysForRBF (nConflictingFees, nModifiedFees , ws.m_vsize ,
855
+ if (const auto err_string{PaysForRBF (ws. m_conflicting_fees , ws. m_modified_fees , ws.m_vsize ,
862
856
::incrementalRelayFee, hash)}) {
863
857
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " insufficient fee" , *err_string);
864
858
}
@@ -931,24 +925,19 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
931
925
TxValidationState& state = ws.m_state ;
932
926
const bool bypass_limits = args.m_bypass_limits ;
933
927
934
- CTxMemPool::setEntries& allConflicting = ws.m_all_conflicting ;
935
- CTxMemPool::setEntries& setAncestors = ws.m_ancestors ;
936
- const CAmount& nModifiedFees = ws.m_modified_fees ;
937
- const CAmount& nConflictingFees = ws.m_conflicting_fees ;
938
- const size_t & nConflictingSize = ws.m_conflicting_size ;
939
928
std::unique_ptr<CTxMemPoolEntry>& entry = ws.m_entry ;
940
929
941
930
// Remove conflicting transactions from the mempool
942
- for (CTxMemPool::txiter it : allConflicting )
931
+ for (CTxMemPool::txiter it : ws. m_all_conflicting )
943
932
{
944
933
LogPrint (BCLog::MEMPOOL, " replacing tx %s with %s for %s additional fees, %d delta bytes\n " ,
945
934
it->GetTx ().GetHash ().ToString (),
946
935
hash.ToString (),
947
- FormatMoney (nModifiedFees - nConflictingFees ),
948
- (int )entry->GetTxSize () - (int )nConflictingSize );
936
+ FormatMoney (ws. m_modified_fees - ws. m_conflicting_fees ),
937
+ (int )entry->GetTxSize () - (int )ws. m_conflicting_size );
949
938
ws.m_replaced_transactions .push_back (it->GetSharedTx ());
950
939
}
951
- m_pool.RemoveStaged (allConflicting , false , MemPoolRemovalReason::REPLACED);
940
+ m_pool.RemoveStaged (ws. m_all_conflicting , false , MemPoolRemovalReason::REPLACED);
952
941
953
942
// This transaction should only count for fee estimation if:
954
943
// - it's not being re-added during a reorg which bypasses typical mempool fee limits
@@ -957,7 +946,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
957
946
bool validForFeeEstimation = !bypass_limits && IsCurrentForFeeEstimation (m_active_chainstate) && m_pool.HasNoInputsOf (tx);
958
947
959
948
// Store transaction in memory
960
- m_pool.addUnchecked (*entry, setAncestors , validForFeeEstimation);
949
+ m_pool.addUnchecked (*entry, ws. m_ancestors , validForFeeEstimation);
961
950
962
951
// trim mempool and check if tx was trimmed
963
952
if (!bypass_limits) {
0 commit comments