@@ -338,19 +338,19 @@ where
338
338
let base_fee = client. runtime_api ( ) . gas_price ( hash) . unwrap_or_default ( ) ;
339
339
let receipts = handler. current_receipts ( hash) ;
340
340
let mut result = FeeHistoryCacheItem {
341
- base_fee : if base_fee > U256 :: from ( u64:: MAX ) { u64 :: MAX } else { base_fee . low_u64 ( ) } ,
341
+ base_fee : UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( base_fee ) ,
342
342
gas_used_ratio : 0f64 ,
343
343
rewards : Vec :: new ( ) ,
344
344
} ;
345
345
if let ( Some ( block) , Some ( receipts) ) = ( block, receipts) {
346
- block_number = Some ( block. header . number . as_u64 ( ) ) ;
347
- let gas_used = block. header . gas_used . as_u64 ( ) as f64 ;
348
- let gas_limit = block. header . gas_limit . as_u64 ( ) as f64 ;
346
+ block_number = Some ( UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( block. header . number ) ) ;
347
+ let gas_used = UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( block. header . gas_used ) as f64 ;
348
+ let gas_limit = UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( block. header . gas_limit ) as f64 ;
349
349
result. gas_used_ratio = gas_used / gas_limit;
350
350
351
351
let mut previous_cumulative_gas = U256 :: zero ( ) ;
352
352
let used_gas = |current : U256 , previous : & mut U256 | -> u64 {
353
- let r = current. saturating_sub ( * previous) . as_u64 ( ) ;
353
+ let r = UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( current. saturating_sub ( * previous) ) ;
354
354
* previous = current;
355
355
r
356
356
} ;
@@ -364,15 +364,16 @@ where
364
364
} ,
365
365
effective_reward : match block. transactions . get ( i) {
366
366
Some ( ethereum:: TransactionV2 :: Legacy ( t) ) => {
367
- t. gas_price . saturating_sub ( base_fee) . as_u64 ( )
367
+ UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( t. gas_price . saturating_sub ( base_fee) )
368
368
}
369
369
Some ( ethereum:: TransactionV2 :: EIP2930 ( t) ) => {
370
- t. gas_price . saturating_sub ( base_fee) . as_u64 ( )
370
+ UniqueSaturatedInto :: < u64 > :: unique_saturated_into ( t. gas_price . saturating_sub ( base_fee) )
371
371
}
372
- Some ( ethereum:: TransactionV2 :: EIP1559 ( t) ) => t
373
- . max_priority_fee_per_gas
374
- . min ( t. max_fee_per_gas . saturating_sub ( base_fee) )
375
- . as_u64 ( ) ,
372
+ Some ( ethereum:: TransactionV2 :: EIP1559 ( t) ) => UniqueSaturatedInto :: < u64 > :: unique_saturated_into (
373
+ t
374
+ . max_priority_fee_per_gas
375
+ . min ( t. max_fee_per_gas . saturating_sub ( base_fee) )
376
+ ) ,
376
377
None => 0 ,
377
378
} ,
378
379
} )
0 commit comments