Skip to content

Commit

Permalink
Use asset exchange rates when validating package fee rates
Browse files Browse the repository at this point in the history
  • Loading branch information
JBetz committed Apr 23, 2024
1 parent a6b3d08 commit ce0d89d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,17 +649,17 @@ class MemPoolAccept
EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);

// Compare a package's feerate against minimum allowed.
bool CheckFeeRate(size_t package_size, CAmount package_fee, TxValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_pool.cs)
bool CheckFeeRate(size_t package_size, CAmount package_fee, CAsset& fee_asset, TxValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_pool.cs)
{
AssertLockHeld(::cs_main);
AssertLockHeld(m_pool.cs);
CAmount mempoolRejectFee = m_pool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(package_size);
CAmount mempoolRejectFee = m_pool.GetMinFee(gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(package_size, fee_asset);
if (mempoolRejectFee > 0 && package_fee < mempoolRejectFee) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool min fee not met", strprintf("%d < %d", package_fee, mempoolRejectFee));
}

if (package_fee < ::minRelayTxFee.GetFee(package_size)) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met", strprintf("%d < %d", package_fee, ::minRelayTxFee.GetFee(package_size)));
if (package_fee < ::minRelayTxFee.GetFee(package_size, fee_asset)) {
return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met", strprintf("%d < %d", package_fee, ::minRelayTxFee.GetFee(package_size, fee_asset)));
}
return true;
}
Expand Down Expand Up @@ -930,7 +930,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
if (g_con_any_asset_fees) {
totalFees = ExchangeRateMap::GetInstance().CalculateExchangeValue(totalFees, feeAsset);
}
if (!bypass_limits && !CheckFeeRate(ws.m_vsize, totalFees, state)) return false;
if (!bypass_limits && !CheckFeeRate(ws.m_vsize, totalFees, feeAsset, state)) return false;

ws.m_iters_conflicting = m_pool.GetIterSet(ws.m_conflicts);
// Calculate in-mempool ancestors, up to a limit.
Expand Down

0 comments on commit ce0d89d

Please sign in to comment.