diff --git a/core/src/pow/types.rs b/core/src/pow/types.rs index 505957c5e..6e287da7f 100644 --- a/core/src/pow/types.rs +++ b/core/src/pow/types.rs @@ -76,11 +76,6 @@ impl Difficulty { Difficulty { num: max(num, 1) } } - /// Compute difficulty scaling factor for graph defined by 2 * 2^edge_bits * edge_bits bits - pub fn scale(edge_bits: u8) -> u64 { - (2 << (edge_bits - global::base_edge_bits()) as u64) * (edge_bits as u64) - } - /// Computes the difficulty from a hash. Divides the maximum target by the /// provided hash and applies the Cuck(at)oo size adjustment factor (see /// https://lists.launchpad.net/mimblewimble/msg00494.html). diff --git a/servers/src/common/stats.rs b/servers/src/common/stats.rs index e3f8c8807..571b6a9ca 100644 --- a/servers/src/common/stats.rs +++ b/servers/src/common/stats.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::time::SystemTime; use util::RwLock; -use core::pow::Difficulty; +use core::consensus::graph_weight; use chrono::prelude::*; @@ -164,8 +164,7 @@ pub struct PeerStats { impl StratumStats { /// Calculate network hashrate pub fn network_hashrate(&self) -> f64 { - 42.0 * (self.network_difficulty as f64 / Difficulty::scale(self.edge_bits as u8) as f64) - / 60.0 + 42.0 * (self.network_difficulty as f64 / graph_weight(self.edge_bits as u8) as f64) / 60.0 } } diff --git a/servers/src/grin/server.rs b/servers/src/grin/server.rs index 52bbd36a3..36cb854bc 100644 --- a/servers/src/grin/server.rs +++ b/servers/src/grin/server.rs @@ -400,7 +400,6 @@ impl Server { let mut last_time = last_blocks[0].timestamp; let tip_height = self.chain.head().unwrap().height as i64; let earliest_block_height = tip_height as i64 - last_blocks.len() as i64; - let mut i = 1; let diff_entries: Vec = last_blocks @@ -408,7 +407,7 @@ impl Server { .skip(1) .map(|n| { let dur = n.timestamp - last_time; - let height = earliest_block_height + i + 1; + let height = earliest_block_height + i; i += 1; last_time = n.timestamp; DiffBlock {