From 6e47d57744a4ddc76b13b12586ded228525b4707 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 30 Jan 2024 07:57:30 +1100 Subject: [PATCH] Rename difficulty transition threshold functions These two functions calculate the min/max threshold transition which is a _target_ not a "difficulty" number. Using "difficulty" in the function name is unnecessarily confusing. Rename and deprecate the functions. --- bitcoin/src/pow.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index eec84379..3e28029a 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -253,19 +253,30 @@ impl Target { #[cfg_attr(all(test, mutate), mutate)] pub fn difficulty_float(&self) -> f64 { TARGET_MAX_F64 / self.0.to_f64() } + /// Computes the minimum valid [`Target`] threshold allowed for a block in which a difficulty + /// adjustment occurs. + #[deprecated(since = "TBD", note = "use min_transition_threshold instead")] + pub fn min_difficulty_transition_threshold(&self) -> Self { self.min_transition_threshold() } + + /// Computes the maximum valid [`Target`] threshold allowed for a block in which a difficulty + /// adjustment occurs. + #[deprecated(since = "TBD", note = "use max_transition_threshold instead")] + pub fn max_difficulty_transition_threshold(&self) -> Self { self.max_transition_threshold() } + /// Computes the minimum valid [`Target`] threshold allowed for a block in which a difficulty /// adjustment occurs. /// /// The difficulty can only decrease or increase by a factor of 4 max on each difficulty /// adjustment period. - pub fn min_difficulty_transition_threshold(&self) -> Self { Self(self.0 >> 2) } + pub fn min_transition_threshold(&self) -> Self { Self(self.0 >> 2) } /// Computes the maximum valid [`Target`] threshold allowed for a block in which a difficulty /// adjustment occurs. /// /// The difficulty can only decrease or increase by a factor of 4 max on each difficulty /// adjustment period. - pub fn max_difficulty_transition_threshold(&self) -> Self { Self(self.0 << 2) } + pub fn max_transition_threshold(&self) -> Self { Self(self.0 << 2) } + } do_impl!(Target);