File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
aggregation_mode/src/backend Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use alloy::{
2121} ;
2222use config:: Config ;
2323use ethers:: types:: U256 ;
24+ use ethers:: utils:: parse_ether;
2425use fetcher:: { ProofsFetcher , ProofsFetcherError } ;
2526use merkle_tree:: compute_proofs_merkle_root;
2627use risc0_ethereum_contracts:: encode_seal;
@@ -177,16 +178,11 @@ impl ProofAggregator {
177178 Ok ( ( ) )
178179 }
179180
180- fn floating_eth_to_wei ( eth : f64 ) -> U256 {
181- let wei_in_eth = 1_000_000_000_000_000_000f64 ;
182- let wei = eth * wei_in_eth;
183- U256 :: from ( wei as u64 )
184- }
185-
186181 fn max_to_spend_in_wei ( time_elapsed : Duration , monthly_eth_budget : f64 ) -> U256 {
187182 const SECONDS_PER_MONTH : u64 = 30 * 24 * 60 * 60 ;
188183
189- let monthly_budget_in_wei = Self :: floating_eth_to_wei ( monthly_eth_budget) ;
184+ // Note: this unwrap is safe because parse_ether only fails for negative numbers or invalid strings
185+ let monthly_budget_in_wei = parse_ether ( monthly_eth_budget) . unwrap_or ( U256 :: zero ( ) ) ;
190186
191187 let elapsed_seconds = U256 :: from ( time_elapsed. as_secs ( ) ) ;
192188
You can’t perform that action at this time.
0 commit comments