Fix bug that crashes network with probability 2^-64 (#2358)
This commit is contained in:
committed by
Ignotus Peverell
parent
e93b380a06
commit
762da8c491
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user