From 1ae2e905d8004c044b0f46e48a3caf0d8ef42a26 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Thu, 25 May 2017 17:42:29 -0700 Subject: [PATCH] Printing difficulty while mining --- core/src/core/target.rs | 6 ++++++ grin/src/miner.rs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/core/target.rs b/core/src/core/target.rs index 0d615960..40bb0e6e 100644 --- a/core/src/core/target.rs +++ b/core/src/core/target.rs @@ -68,6 +68,12 @@ impl Difficulty { } } +impl fmt::Display for Difficulty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.num) + } +} + impl Add for Difficulty { type Output = Difficulty; fn add(self, other: Difficulty) -> Difficulty { diff --git a/grin/src/miner.rs b/grin/src/miner.rs index a23e30f4..3c27b65d 100644 --- a/grin/src/miner.rs +++ b/grin/src/miner.rs @@ -74,9 +74,10 @@ impl Miner { // transactions) and as long as the head hasn't changed let deadline = time::get_time().sec + 2; let mut sol = None; - debug!("Mining at Cuckoo{} for at most 2 secs on block {}.", + debug!("Mining at Cuckoo{} for at most 2 secs on block {} at difficulty {}.", b.header.cuckoo_len, - latest_hash); + latest_hash, + b.header.difficulty); let mut iter_count = 0; while head.hash() == latest_hash && time::get_time().sec < deadline { let pow_hash = b.hash();