From 7b6e219b5b42165d589b5f5b3c3282199e10779d Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Wed, 19 Sep 2018 18:30:52 +0000 Subject: [PATCH] Minor: move raw_difficulty to Proof --- core/src/pow/types.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/pow/types.rs b/core/src/pow/types.rs index bb8321e5b..c1c40d37c 100644 --- a/core/src/pow/types.rs +++ b/core/src/pow/types.rs @@ -60,7 +60,7 @@ impl Difficulty { let shift = proof.cuckoo_sizeshift; let adjust_factor = (1 << (shift - global::ref_sizeshift()) as u64) * (shift as u64 - 1); - Difficulty::from_num(Difficulty::raw_difficulty(proof) * adjust_factor) + Difficulty::from_num(proof.raw_difficulty() * adjust_factor) } /// Same as `from_proof_adjusted` but instead of an adjustment based on @@ -68,11 +68,7 @@ impl Difficulty { /// to scale one PoW against the other. pub fn from_proof_scaled(proof: &Proof, scaling: u64) -> Difficulty { // Scaling between 2 proof of work algos - Difficulty::from_num(Difficulty::raw_difficulty(proof) * scaling) - } - - fn raw_difficulty(proof: &Proof) -> u64 { - ::max_value() / proof.hash().to_u64() + Difficulty::from_num(proof.raw_difficulty() * scaling) } /// Converts the difficulty into a u64 @@ -344,6 +340,11 @@ impl Proof { pub fn proof_size(&self) -> usize { self.nonces.len() } + + /// Difficulty achieved by this proof + fn raw_difficulty(&self) -> u64 { + ::max_value() / self.hash().to_u64() + } } impl Readable for Proof {