From 762da8c491c5892880d0aea5b7798570aa7c56b4 Mon Sep 17 00:00:00 2001 From: John Tromp Date: Sat, 12 Jan 2019 19:41:22 +0100 Subject: [PATCH] Fix bug that crashes network with probability 2^-64 (#2358) --- core/src/pow/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/pow/types.rs b/core/src/pow/types.rs index 6d71a321c..68b7e9867 100644 --- a/core/src/pow/types.rs +++ b/core/src/pow/types.rs @@ -383,7 +383,7 @@ impl Proof { /// Difficulty achieved by this proof with given scaling factor fn scaled_difficulty(&self, scale: u64) -> u64 { - let diff = ((scale as u128) << 64) / (self.hash().to_u64() as u128); + let diff = ((scale as u128) << 64) / (max(1, self.hash().to_u64()) as u128); min(diff, ::max_value() as u128) as u64 } }