Run the formatter

This commit is contained in:
Tobin C. Harding 2025-05-08 10:16:56 +10:00
parent 7c2115b68f
commit d557caf552
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
8 changed files with 30 additions and 23 deletions

View File

@ -30,9 +30,7 @@ use crate::transaction::{Transaction, TransactionExt as _, Wtxid};
#[doc(inline)]
pub use primitives::block::{Block, Checked, Unchecked, Validation, Version, BlockHash, Header, WitnessCommitment};
#[doc(inline)]
pub use units::block::{
BlockHeight, BlockHeightInterval, TooBigForRelativeHeightError,
};
pub use units::block::{BlockHeight, BlockHeightInterval, TooBigForRelativeHeightError};
#[deprecated(since = "TBD", note = "use `BlockHeightInterval` instead")]
#[doc(hidden)]

View File

@ -71,8 +71,8 @@ pub mod locktime {
/// Re-export everything from the `primitives::locktime::relative` module.
pub use primitives::locktime::relative::{
DisabledLockTimeError, NumberOfBlocks, IncompatibleHeightError, IncompatibleTimeError,
LockTime, NumberOf512Seconds, TimeOverflowError,
DisabledLockTimeError, IncompatibleHeightError, IncompatibleTimeError, LockTime,
NumberOf512Seconds, NumberOfBlocks, TimeOverflowError,
};
#[deprecated(since = "TBD", note = "use `NumberOfBlocks` instead")]

View File

@ -378,7 +378,10 @@ impl LockTime {
/// assert!(lock.is_satisfied_by_time(relative::Time::from_512_second_intervals(intervals + 10)).expect("a time"));
/// ```
#[inline]
pub fn is_satisfied_by_time(self, time: NumberOf512Seconds) -> Result<bool, IncompatibleTimeError> {
pub fn is_satisfied_by_time(
self,
time: NumberOf512Seconds,
) -> Result<bool, IncompatibleTimeError> {
use LockTime as L;
match self {
@ -589,15 +592,12 @@ mod tests {
let time = NumberOf512Seconds::from_512_second_intervals(70);
let lock_by_time = LockTime::from(time);
assert!(
!lock_by_time.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(69)))
);
assert!(
lock_by_time.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(70)))
);
assert!(
lock_by_time.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(71)))
);
assert!(!lock_by_time
.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(69))));
assert!(lock_by_time
.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(70))));
assert!(lock_by_time
.is_implied_by(LockTime::from(NumberOf512Seconds::from_512_second_intervals(71))));
}
#[test]

View File

@ -187,7 +187,7 @@ impl Sequence {
/// Constructs a new [`relative::LockTime`] from this [`Sequence`] number.
#[inline]
pub fn to_relative_lock_time(self) -> Option<relative::LockTime> {
use crate::locktime::relative::{NumberOfBlocks, LockTime, NumberOf512Seconds};
use crate::locktime::relative::{LockTime, NumberOf512Seconds, NumberOfBlocks};
if !self.is_relative_lock_time() {
return None;

View File

@ -217,7 +217,9 @@ impl TryFrom<BlockMtp> for absolute::MedianTimePast {
///
/// An absolute locktime MTP has a minimum value of [`absolute::LOCK_TIME_THRESHOLD`],
/// while [`BlockMtp`] may take the full range of `u32`.
fn try_from(h: BlockMtp) -> Result<Self, Self::Error> { absolute::MedianTimePast::from_u32(h.to_u32()) }
fn try_from(h: BlockMtp) -> Result<Self, Self::Error> {
absolute::MedianTimePast::from_u32(h.to_u32())
}
}
impl_u32_wrapper! {

View File

@ -405,7 +405,12 @@ impl ParseError {
)
}
E::ParseInt(ParseIntError { input, bits: _, is_signed: _, source: _ }) => {
write!(f, "{} ({})", input.display_cannot_parse("absolute Height/MedianTimePast"), subject)
write!(
f,
"{} ({})",
input.display_cannot_parse("absolute Height/MedianTimePast"),
subject
)
}
E::Conversion(value) if *value < i64::from(lower_bound) => {
write!(f, "{} {} is below limit {}", subject, value, lower_bound)

View File

@ -286,7 +286,10 @@ mod tests {
fn sanity_check() {
assert_eq!(NumberOfBlocks::MAX.to_consensus_u32(), u32::from(u16::MAX));
assert_eq!(NumberOf512Seconds::from_512_second_intervals(100).value(), 100u16);
assert_eq!(NumberOf512Seconds::from_512_second_intervals(100).to_consensus_u32(), 4_194_404u32); // 0x400064
assert_eq!(
NumberOf512Seconds::from_512_second_intervals(100).to_consensus_u32(),
4_194_404u32
); // 0x400064
}
#[test]
@ -325,7 +328,8 @@ mod tests {
#[test]
fn from_seconds_floor_with_maximum_encodable_seconds_success() {
let actual = NumberOf512Seconds::from_seconds_floor(MAXIMUM_ENCODABLE_SECONDS + 511).unwrap();
let actual =
NumberOf512Seconds::from_seconds_floor(MAXIMUM_ENCODABLE_SECONDS + 511).unwrap();
let expected = NumberOf512Seconds(u16::MAX);
assert_eq!(actual, expected);
}

View File

@ -171,9 +171,7 @@ fn api_can_use_all_types_from_module_amount() {
#[test]
fn api_can_use_all_types_from_module_block() {
use bitcoin_units::block::{
BlockHeight, BlockHeightInterval, TooBigForRelativeHeightError,
};
use bitcoin_units::block::{BlockHeight, BlockHeightInterval, TooBigForRelativeHeightError};
}
#[test]