Skip to content

Commit

Permalink
Revert "separate priority fee and transaction fee from fee calculation (
Browse files Browse the repository at this point in the history
#34757)"

This reverts commit 5ecc47e.
  • Loading branch information
tao-stones committed Jan 30, 2024
1 parent 1542392 commit df2ee12
Showing 1 changed file with 8 additions and 39 deletions.
47 changes: 8 additions & 39 deletions sdk/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ pub struct FeeStructure {
pub compute_fee_bins: Vec<FeeBin>,
}

/// Return type of calculate_fee(...)
#[derive(Debug, Default, Clone, Eq, PartialEq)]
pub struct FeeDetails {
transaction_fee: u64,
prioritization_fee: u64,
}

impl FeeDetails {
pub fn total_fee(&self) -> u64 {
self.transaction_fee.saturating_add(self.prioritization_fee)
}
}

pub const ACCOUNT_DATA_COST_PAGE_SIZE: u64 = 32_u64.saturating_mul(1024);

impl FeeStructure {
Expand Down Expand Up @@ -88,32 +75,15 @@ impl FeeStructure {
.saturating_mul(heap_cost)
}

/// Calculate fee for `SanitizedMessage`
#[cfg(not(target_os = "solana"))]
pub fn calculate_fee(
&self,
message: &SanitizedMessage,
lamports_per_signature: u64,
budget_limits: &FeeBudgetLimits,
include_loaded_account_data_size_in_fee: bool,
) -> u64 {
self.calculate_fee_details(
message,
lamports_per_signature,
budget_limits,
include_loaded_account_data_size_in_fee,
)
.total_fee()
}

/// Calculate fee details for `SanitizedMessage`
#[cfg(not(target_os = "solana"))]
pub fn calculate_fee_details(
&self,
message: &SanitizedMessage,
_lamports_per_signature: u64,
budget_limits: &FeeBudgetLimits,
include_loaded_account_data_size_in_fee: bool,
) -> FeeDetails {
) -> u64 {
let signature_fee = message
.num_signatures()
.saturating_mul(self.lamports_per_signature);
Expand Down Expand Up @@ -145,13 +115,12 @@ impl FeeStructure {
.unwrap_or_default()
});

FeeDetails {
transaction_fee: (signature_fee
.saturating_add(write_lock_fee)
.saturating_add(compute_fee) as f64)
.round() as u64,
prioritization_fee: budget_limits.prioritization_fee,
}
(budget_limits
.prioritization_fee
.saturating_add(signature_fee)
.saturating_add(write_lock_fee)
.saturating_add(compute_fee) as f64)
.round() as u64
}
}

Expand Down

0 comments on commit df2ee12

Please sign in to comment.