File tree Expand file tree Collapse file tree 2 files changed +2
-26
lines changed
crates/fuel-gas-price-algorithm/src Expand file tree Collapse file tree 2 files changed +2
-26
lines changed Original file line number Diff line number Diff line change @@ -18,24 +18,3 @@ pub(crate) fn cumulative_percentage_change(
1818 // `f64` over `u64::MAX` are cast to `u64::MAX`
1919 approx. ceil ( ) as u64
2020}
21-
22- pub ( crate ) fn safe_signed_abs ( n : i128 ) -> i128 {
23- let n = if n == i128:: MIN {
24- n. saturating_add ( 1 )
25- } else {
26- n
27- } ;
28- debug_assert ! ( n != i128 :: MIN ) ;
29- n. abs ( )
30- }
31-
32- #[ cfg( test) ]
33- mod tests {
34- use crate :: utils:: safe_signed_abs;
35-
36- #[ test]
37- fn safe_signed_abs_does_not_overflow_on_min_value ( ) {
38- let abs = safe_signed_abs ( i128:: MIN ) ;
39- assert_eq ! ( abs, i128 :: MAX ) ;
40- }
41- }
Original file line number Diff line number Diff line change @@ -4,10 +4,7 @@ use std::{
44 ops:: Div ,
55} ;
66
7- use crate :: utils:: {
8- cumulative_percentage_change,
9- safe_signed_abs,
10- } ;
7+ use crate :: utils:: cumulative_percentage_change;
118
129#[ cfg( test) ]
1310mod tests;
@@ -334,7 +331,7 @@ impl AlgorithmUpdaterV1 {
334331 . saturating_mul ( upcast_percent)
335332 . saturating_div ( 100 )
336333 . into ( ) ;
337- let clamped_change = safe_signed_abs ( pd_change) . min ( max_change) ;
334+ let clamped_change = pd_change. saturating_abs ( ) . min ( max_change) ;
338335 pd_change. signum ( ) . saturating_mul ( clamped_change)
339336 }
340337
You can’t perform that action at this time.
0 commit comments