From 8f70244856e4db9108a1002958fadb6cca23fb72 Mon Sep 17 00:00:00 2001
From: Anthony Graignic <anthony.graignic@uca.fr>
Date: Fri, 15 Mar 2024 12:40:44 +0100
Subject: [PATCH] Fix optional miner quantity hack

---
 src/main.rs | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index a965670..6c74af4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -272,8 +272,9 @@ async fn main() -> Result<(), anyhow::Error> {
                 let simulation_behavior = mobility_records[i].clone();
                 let relative_start_duration = if i == 0 {
                     Duration::from_secs(0)
-                }
-                else { mobility_records_times[i] - mobility_records_times[i - 1] };
+                } else {
+                    mobility_records_times[i] - mobility_records_times[i - 1]
+                };
                 let rpc_url = rpc_url.clone();
                 let chain_id = chain_id;
                 let mut time_since_beginning = now;
@@ -449,11 +450,15 @@ async fn main() -> Result<(), anyhow::Error> {
             info!("Mining with 0x{:02x} ...", miner_addr);
 
             let provider = Provider::<Http>::try_from(rpc_url.clone()).unwrap();
-            let latest_block = provider.get_block(BlockNumber::Latest).await;
-            let network_difficulty = Some(
-                ethnum::U256::from_str(&latest_block.unwrap().unwrap().difficulty.to_string())
-                    .unwrap(),
-            );
+            let network_difficulty = if params.desired_vdf_duration.is_some() {
+                let latest_block = provider.get_block(BlockNumber::Latest).await;
+                Some(
+                    ethnum::U256::from_str(&latest_block.unwrap().unwrap().difficulty.to_string())
+                        .unwrap(),
+                )
+            } else {
+                None
+            };
 
             let behavior = get_miner_behavior(
                 wallet,
-- 
GitLab