Fix bug that crashes network with probability 2^-64 (#2358)

This commit is contained in:
John Tromp 2019-01-12 19:41:22 +01:00 committed by Ignotus Peverell
parent e93b380a06
commit 762da8c491

View file

@ -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, <u64>::max_value() as u128) as u64
}
}