Skip to content

Commit

Permalink
fix: check for zero hashrate
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Aug 27, 2024
1 parent f567eda commit d256b85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src-tauri/src/cpu_miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ impl CpuMiner {
Ok(xmrig_status) => {
println!("xmrig status: {:?}", xmrig_status.hashrate.total[0]);
let hash_rate = xmrig_status.hashrate.total[0].unwrap_or_default();
let estimated_earnings = ((block_reward.as_u64() as f64)
* ((hash_rate / (network_hash_rate as f64))
* (RANDOMX_BLOCKS_PER_DAY as f64)))
as u64;
let estimated_earnings = if network_hash_rate == 0 {
0
} else {
((block_reward.as_u64() as f64)
* ((hash_rate / (network_hash_rate as f64))
* (RANDOMX_BLOCKS_PER_DAY as f64)))
as u64
};
// Can't be more than the max reward for a day
let estimated_earnings = std::cmp::min(
estimated_earnings,
Expand Down

0 comments on commit d256b85

Please sign in to comment.