Merge rust-bitcoin/rust-bitcoin#3462: Automated nightly rustfmt (2024-10-13)
f1733309e0
2024-10-13 automated rustfmt nightly (Fmt Bot) Pull request description: Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action ACKs for top commit: apoelstra: ACKf1733309e0
successfully ran local tests Tree-SHA512: 465336b92d9b8a61afbc8e8d0560f3b41a732e3245d764447cc2a5429f693e29172bebeca756a91b5a1f3a16d42728960a526111bbd92316f72b46b420373641
This commit is contained in:
commit
cc5b46bfc7
|
@ -113,8 +113,9 @@ pub fn decode_check(data: &str) -> Result<Vec<u8>, Error> {
|
|||
}
|
||||
let check_start = ret.len() - 4;
|
||||
|
||||
let hash_check =
|
||||
sha256d::Hash::hash(&ret[..check_start]).as_byte_array()[..4].try_into().expect("4 byte slice");
|
||||
let hash_check = sha256d::Hash::hash(&ret[..check_start]).as_byte_array()[..4]
|
||||
.try_into()
|
||||
.expect("4 byte slice");
|
||||
let data_check = ret[check_start..].try_into().expect("4 byte slice");
|
||||
|
||||
let expected = u32::from_le_bytes(hash_check);
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
use hashes::{sha256d, HashEngine};
|
||||
use internals::compact_size;
|
||||
use io::{BufRead, Write};
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
|
||||
use super::Weight;
|
||||
use crate::consensus::{encode, Decodable, Encodable};
|
||||
|
@ -411,7 +411,7 @@ impl<'a> Arbitrary<'a> for Header {
|
|||
merkle_root: TxMerkleNode::from_byte_array(u.arbitrary()?),
|
||||
time: u.arbitrary()?,
|
||||
bits: CompactTarget::from_consensus(u.arbitrary()?),
|
||||
nonce: u.arbitrary()?
|
||||
nonce: u.arbitrary()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -419,10 +419,7 @@ impl<'a> Arbitrary<'a> for Header {
|
|||
#[cfg(feature = "arbitrary")]
|
||||
impl<'a> Arbitrary<'a> for Block {
|
||||
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||
Ok(Block {
|
||||
header: Header::arbitrary(u)?,
|
||||
txdata: Vec::<Transaction>::arbitrary(u)?,
|
||||
})
|
||||
Ok(Block { header: Header::arbitrary(u)?, txdata: Vec::<Transaction>::arbitrary(u)? })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,10 +70,7 @@ pub mod serde_details {
|
|||
/// Default serialization/deserialization methods.
|
||||
pub trait SerdeHash
|
||||
where
|
||||
Self: Sized
|
||||
+ FromStr
|
||||
+ fmt::Display
|
||||
+ crate::Hash,
|
||||
Self: Sized + FromStr + fmt::Display + crate::Hash,
|
||||
<Self as FromStr>::Err: fmt::Display,
|
||||
{
|
||||
/// Size, in bits, of the hash.
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//! module describes structures and functions needed to describe
|
||||
//! these blocks and the blockchain.
|
||||
|
||||
use hashes::sha256d;
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
use hashes::sha256d;
|
||||
|
||||
/// Bitcoin block version number.
|
||||
///
|
||||
|
@ -102,7 +102,7 @@ impl<'a> Arbitrary<'a> for Version {
|
|||
0 => Ok(Version::ONE),
|
||||
1 => Ok(Version::TWO),
|
||||
2 => Ok(Version::NO_SOFT_FORK_SIGNALLING),
|
||||
_ => Ok(Version::from_consensus(u.arbitrary()?))
|
||||
_ => Ok(Version::from_consensus(u.arbitrary()?)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
//! This module mainly introduces the [`Amount`] and [`SignedAmount`] types.
|
||||
//! We refer to the documentation on the types for more information.
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use crate::{Weight, FeeRate};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use alloc::string::{String, ToString};
|
||||
use core::cmp::Ordering;
|
||||
|
@ -21,6 +18,9 @@ use arbitrary::{Arbitrary, Unstructured};
|
|||
use internals::error::InputString;
|
||||
use internals::write_err;
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
use crate::{FeeRate, Weight};
|
||||
|
||||
/// A set of denominations in which amounts can be expressed.
|
||||
///
|
||||
/// # Accepted Denominations
|
||||
|
@ -2242,16 +2242,12 @@ mod tests {
|
|||
#[test]
|
||||
fn amount_checked_div_by_weight() {
|
||||
let weight = Weight::from_kwu(1).unwrap();
|
||||
let fee_rate = Amount::from_sat(1)
|
||||
.checked_div_by_weight(weight)
|
||||
.unwrap();
|
||||
let fee_rate = Amount::from_sat(1).checked_div_by_weight(weight).unwrap();
|
||||
// 1 sats / 1,000 wu = 1 sats/kwu
|
||||
assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(1));
|
||||
|
||||
let weight = Weight::from_wu(381);
|
||||
let fee_rate = Amount::from_sat(329)
|
||||
.checked_div_by_weight(weight)
|
||||
.unwrap();
|
||||
let fee_rate = Amount::from_sat(329).checked_div_by_weight(weight).unwrap();
|
||||
// 329 sats / 381 wu = 863.5 sats/kwu
|
||||
// round up to 864
|
||||
assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(864));
|
||||
|
|
Loading…
Reference in New Issue