Skip to content

Commit 4b6b55f

Browse files
committed
Merge rust-bitcoin#2196: Backport rust-bitcoin#1820 and bump minor version 0.30.2
ba99aa4 Bump version to 0.30.2 (Tobin C. Harding) 3c9bbca Expose valid (min, max) difficulty transition thresholds (Wilmer Paulino) Pull request description: Patch one backports rust-bitcoin#1820, I believe this is all that is needed for LDK to be able to upgrade to `rust-bitcoin v0.30`. Context: - rust-bitcoin#1820 - lightningdevkit/rust-lightning#2124 Patch 2 adds a changelog entry and bumps the minor version. ACKs for top commit: Kixunil: ACK ba99aa4 Tree-SHA512: 93adb52bbc8e61ece63e5653dea7cf6d2d25028f25cb8bbda14606d9ebf74becaee0a0c4f4f3d7fde56c0e2b8a57f8c9be263e04833161a1da0baaf8fcca8764
2 parents 4642021 + ba99aa4 commit 4b6b55f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

bitcoin/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.30.2 - 2023-11-16
2+
3+
- Expose valid (min, max) difficulty transition thresholds [#1820](Expose valid (min, max) difficulty transition thresholds)
4+
15
# 0.30.1 - 2023-07-16
26

37
- Fix compilation when [`RUSTFLAGS=--cfg=bench` is set](https://github.com/rust-bitcoin/rust-bitcoin/pull/1943)

bitcoin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bitcoin"
3-
version = "0.30.1"
3+
version = "0.30.2"
44
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
55
license = "CC0-1.0"
66
repository = "https://github.com/rust-bitcoin/rust-bitcoin/"

bitcoin/src/pow.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ impl Target {
235235
/// [`difficulty`]: Target::difficulty
236236
#[cfg_attr(all(test, mutate), mutate)]
237237
pub fn difficulty_float(&self) -> f64 { TARGET_MAX_F64 / self.0.to_f64() }
238+
239+
/// Computes the minimum valid [`Target`] threshold allowed for a block in which a difficulty
240+
/// adjustment occurs.
241+
///
242+
/// The difficulty can only decrease or increase by a factor of 4 max on each difficulty
243+
/// adjustment period.
244+
pub fn min_difficulty_transition_threshold(&self) -> Self { Self(self.0 >> 2) }
245+
246+
/// Computes the maximum valid [`Target`] threshold allowed for a block in which a difficulty
247+
/// adjustment occurs.
248+
///
249+
/// The difficulty can only decrease or increase by a factor of 4 max on each difficulty
250+
/// adjustment period.
251+
pub fn max_difficulty_transition_threshold(&self) -> Self { Self(self.0 << 2) }
238252
}
239253
do_impl!(Target);
240254

0 commit comments

Comments
 (0)