From 81d4dab755f220cd25ab861bde7c803e7d1b6709 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 30 Jun 2024 08:48:37 -0700 Subject: [PATCH] Add more asserts --- src/priority_fee.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/priority_fee.rs b/src/priority_fee.rs index 278dc6a..ec8e632 100644 --- a/src/priority_fee.rs +++ b/src/priority_fee.rs @@ -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, @@ -105,6 +106,8 @@ pub fn apply_priority_fee( compute_unit_limit: u32, priority_fee: PriorityFee, ) -> Result> { + assert_ne!(compute_unit_limit, 0); + let compute_budget = match priority_fee { PriorityFee::Exact { lamports } => ComputeBudget::new(compute_unit_limit, lamports), PriorityFee::Auto {