`rust-bitcoin v0.30.0` made some changes in this area that no longer
allow us to work with the previously exposed `U256` type. While `Work`
and `Target` (they're inverses of each other) essentially represent the
same concept, it makes more sense from their API's perspective to only
expose difficulty transitions and adjustments on `Target`s.
if let Network::Bitcoin = network {
if self.height % 2016 == 0 {
- let previous_work = previous_header.header.work();
- if work > (previous_work << 2) || work < (previous_work >> 2) {
+ let target = self.header.target();
+ let previous_target = previous_header.header.target();
+ let min_target = previous_target >> 2;
+ let max_target = previous_target << 2;
+ if target > max_target || target < min_target {
return Err(BlockSourceError::persistent("invalid difficulty transition"))
}
} else if self.header.bits != previous_header.header.bits {