Skip to content

Commit c78eb86

Browse files
committed
[policy/refactor] pass in relay fee instead of using global
1 parent 6088115 commit c78eb86

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/policy/rbf.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& i
150150
std::optional<std::string> PaysForRBF(CAmount original_fees,
151151
CAmount replacement_fees,
152152
size_t replacement_vsize,
153+
CFeeRate relay_fee,
153154
const uint256& txid)
154155
{
155156
// The replacement must pay greater fees than the transactions it
@@ -163,11 +164,11 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
163164
// Finally in addition to paying more fees than the conflicts the
164165
// new transaction must pay for its own bandwidth.
165166
CAmount additional_fees = replacement_fees - original_fees;
166-
if (additional_fees < ::incrementalRelayFee.GetFee(replacement_vsize)) {
167+
if (additional_fees < relay_fee.GetFee(replacement_vsize)) {
167168
return strprintf("rejecting replacement %s, not enough additional fees to relay; %s < %s",
168169
txid.ToString(),
169170
FormatMoney(additional_fees),
170-
FormatMoney(::incrementalRelayFee.GetFee(replacement_vsize)));
171+
FormatMoney(relay_fee.GetFee(replacement_vsize)));
171172
}
172173
return std::nullopt;
173174
}

src/policy/rbf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& i
8484
* @param[in] original_fees Total modified fees of original transaction(s).
8585
* @param[in] replacement_fees Total modified fees of replacement transaction(s).
8686
* @param[in] replacement_vsize Total virtual size of replacement transaction(s).
87+
* @param[in] relay_fee The node's minimum feerate for transaction relay.
8788
* @param[in] txid Transaction ID, included in the error message if violation occurs.
8889
* @returns error string if fees are insufficient, otherwise std::nullopt.
8990
*/
9091
std::optional<std::string> PaysForRBF(CAmount original_fees,
9192
CAmount replacement_fees,
9293
size_t replacement_vsize,
94+
CFeeRate relay_fee,
9395
const uint256& txid);
9496

9597
#endif // BITCOIN_POLICY_RBF_H

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
803803
nConflictingFees += it->GetModifiedFee();
804804
nConflictingSize += it->GetTxSize();
805805
}
806-
if (const auto err_string{PaysForRBF(nConflictingFees, nModifiedFees, nSize, hash)}) {
806+
if (const auto err_string{PaysForRBF(nConflictingFees, nModifiedFees, nSize, ::incrementalRelayFee, hash)}) {
807807
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "insufficient fee", *err_string);
808808
}
809809
}

0 commit comments

Comments
 (0)