Skip to content

Commit

Permalink
Add more asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Jun 30, 2024
1 parent 567dcc7 commit 81d4dab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/priority_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct ComputeBudget {

impl ComputeBudget {
pub fn new(compute_unit_limit: u32, priority_fee_lamports: u64) -> Self {
assert_ne!(compute_unit_limit, 0);
Self {
compute_unit_price_micro_lamports: priority_fee_lamports * (1e6 as u64)
/ compute_unit_limit as u64,
Expand Down Expand Up @@ -105,6 +106,8 @@ pub fn apply_priority_fee(
compute_unit_limit: u32,
priority_fee: PriorityFee,
) -> Result<u64, Box<dyn std::error::Error>> {
assert_ne!(compute_unit_limit, 0);

let compute_budget = match priority_fee {
PriorityFee::Exact { lamports } => ComputeBudget::new(compute_unit_limit, lamports),
PriorityFee::Auto {
Expand Down

0 comments on commit 81d4dab

Please sign in to comment.