Skip to content

Commit

Permalink
fix formula for prioritization
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Jan 24, 2024
1 parent 2471be5 commit f8fb19a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
crate::banking_stage::scheduler_messages::TransactionId,
min_max_heap::MinMaxHeap,
solana_cost_model::transaction_cost::TransactionCost,
solana_program_runtime::prioritization_fee::{PrioritizationFeeDetails, PrioritizationFeeType},
solana_runtime::transaction_priority_details::TransactionPriorityDetails,
std::collections::HashMap,
};
Expand Down Expand Up @@ -155,12 +156,19 @@ impl TransactionStateContainer {

/// Calculate prioritization for a transaction.
fn calculate_prioritization(lamports_per_signature: u64, state: &TransactionState) -> u64 {
let compute_unit_price = state.transaction_priority_details().priority;
let priority_details = state.transaction_priority_details();
let priority_fee = PrioritizationFeeDetails::new(
PrioritizationFeeType::ComputeUnitPrice(priority_details.priority),
priority_details.compute_unit_limit,
)
.get_fee();
let signature_fees =
lamports_per_signature * state.transaction_ttl().transaction.signatures().len() as u64;
let cost = state.transaction_cost().sum();

signature_fees / cost + compute_unit_price
signature_fees
.saturating_add(priority_fee)
.saturating_div(cost)
}
}

Expand Down

0 comments on commit f8fb19a

Please sign in to comment.