mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
* Fix shift by 1 block in TUI (#1780) * Only use graph_weight * Fix shift by 1 in block * Remove debug logging
This commit is contained in:
parent
d11088c987
commit
5f2e8db092
3 changed files with 3 additions and 10 deletions
|
@ -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).
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<DiffBlock> = 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 {
|
||||
|
|
Loading…
Reference in a new issue