diff --git a/base_layer/core/src/proof_of_work/accumulated_difficulty.rs b/base_layer/core/src/proof_of_work/accumulated_difficulty.rs index cd5646590b..6dcc2acd1f 100644 --- a/base_layer/core/src/proof_of_work/accumulated_difficulty.rs +++ b/base_layer/core/src/proof_of_work/accumulated_difficulty.rs @@ -59,6 +59,10 @@ impl AccumulatedDifficulty { self.0.checked_add(u128::from(d.as_u64())).map(AccumulatedDifficulty) } + pub fn checked_sub_difficulty(&self, d: Difficulty) -> Option { + self.0.checked_sub(u128::from(d.as_u64())).map(AccumulatedDifficulty) + } + pub fn to_be_bytes(&self) -> Vec { self.0.to_be_bytes().to_vec() }