@@ -84,7 +84,7 @@ pub enum ResourceKind {
8484
8585impl ResourceKind {
8686 /// Returns all resource kinds in a fixed order.
87- pub fn all ( ) -> [ Self ; 4 ] {
87+ pub const fn all ( ) -> [ Self ; 4 ] {
8888 [ Self :: GasUsed , Self :: ExecutionTime , Self :: StateRootTime , Self :: DataAvailability ]
8989 }
9090
@@ -98,7 +98,7 @@ impl ResourceKind {
9898 ///
9999 /// Other resources like gas and DA bytes are bounded per-block but are
100100 /// evaluated per-flashblock since their limits apply independently.
101- fn use_it_or_lose_it ( self ) -> bool {
101+ const fn use_it_or_lose_it ( self ) -> bool {
102102 matches ! ( self , Self :: ExecutionTime )
103103 }
104104
@@ -185,7 +185,7 @@ pub struct ResourceEstimates {
185185
186186impl ResourceEstimates {
187187 /// Returns the estimate for the given resource kind.
188- pub fn get ( & self , kind : ResourceKind ) -> Option < & ResourceEstimate > {
188+ pub const fn get ( & self , kind : ResourceKind ) -> Option < & ResourceEstimate > {
189189 match kind {
190190 ResourceKind :: GasUsed => self . gas_used . as_ref ( ) ,
191191 ResourceKind :: ExecutionTime => self . execution_time . as_ref ( ) ,
@@ -195,7 +195,7 @@ impl ResourceEstimates {
195195 }
196196
197197 /// Sets the estimate for the given resource kind.
198- pub fn set ( & mut self , kind : ResourceKind , estimate : ResourceEstimate ) {
198+ pub const fn set ( & mut self , kind : ResourceKind , estimate : ResourceEstimate ) {
199199 match kind {
200200 ResourceKind :: GasUsed => self . gas_used = Some ( estimate) ,
201201 ResourceKind :: ExecutionTime => self . execution_time = Some ( estimate) ,
@@ -278,7 +278,7 @@ impl PriorityFeeEstimator {
278278 /// - `limits`: Configured resource capacity limits.
279279 /// - `default_priority_fee`: Fee to return when a resource is not congested.
280280 /// - `da_config`: Optional shared DA config for dynamic DA limit updates.
281- pub fn new (
281+ pub const fn new (
282282 cache : Arc < RwLock < MeteringCache > > ,
283283 percentile : f64 ,
284284 limits : ResourceLimits ,
@@ -318,10 +318,8 @@ impl PriorityFeeEstimator {
318318 demand : ResourceDemand ,
319319 ) -> Result < Option < BlockPriorityEstimates > , EstimateError > {
320320 let cache_guard = self . cache . read ( ) ;
321- let block_metrics = match block_number {
322- Some ( target) => cache_guard. block ( target) ,
323- None => cache_guard. blocks_desc ( ) . next ( ) ,
324- } ;
321+ let block_metrics = block_number
322+ . map_or_else ( || cache_guard. blocks_desc ( ) . next ( ) , |target| cache_guard. block ( target) ) ;
325323 let Some ( block_metrics) = block_metrics else {
326324 return Ok ( None ) ;
327325 } ;
@@ -555,8 +553,15 @@ fn compute_estimate(
555553 } ) ;
556554 }
557555
558- let ( supporting_count, threshold_fee, recommended_fee) = match last_included_idx {
559- Some ( idx) => {
556+ let ( supporting_count, threshold_fee, recommended_fee) = last_included_idx. map_or_else (
557+ || {
558+ // No transactions fit - even the first transaction would crowd out
559+ // the bundle. The bundle must beat the highest fee to be included.
560+ // Report 0 supporting transactions since none were actually included.
561+ let threshold_fee = transactions[ 0 ] . priority_fee_per_gas ;
562+ ( 0 , threshold_fee, threshold_fee)
563+ } ,
564+ |idx| {
560565 // At least one transaction fits alongside the bundle.
561566 // The threshold is the fee of the last included transaction.
562567 let threshold_fee = transactions[ idx] . priority_fee_per_gas ;
@@ -574,15 +579,8 @@ fn compute_estimate(
574579 } ;
575580
576581 ( idx + 1 , threshold_fee, recommended_fee)
577- }
578- None => {
579- // No transactions fit - even the first transaction would crowd out
580- // the bundle. The bundle must beat the highest fee to be included.
581- // Report 0 supporting transactions since none were actually included.
582- let threshold_fee = transactions[ 0 ] . priority_fee_per_gas ;
583- ( 0 , threshold_fee, threshold_fee)
584- }
585- } ;
582+ } ,
583+ ) ;
586584
587585 Ok ( ResourceEstimate {
588586 threshold_priority_fee : threshold_fee,
0 commit comments