From 4745b55caed74a09de3304f406374e4c4abcf5a6 Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 16 Jun 2024 01:09:27 +0000 Subject: [PATCH] 2024-06-16 automated rustfmt nightly --- bitcoin/src/consensus/validation.rs | 8 +++++++- bitcoin/src/merkle_tree/block.rs | 13 ++++--------- bitcoin/src/p2p/message.rs | 4 +--- hashes/src/internal_macros.rs | 10 +++++----- hashes/src/sha256t.rs | 14 ++++---------- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/bitcoin/src/consensus/validation.rs b/bitcoin/src/consensus/validation.rs index 483cfc1a1..db4b3d589 100644 --- a/bitcoin/src/consensus/validation.rs +++ b/bitcoin/src/consensus/validation.rs @@ -33,7 +33,13 @@ pub fn verify_script( amount: Amount, spending_tx: &[u8], ) -> Result<(), BitcoinconsensusError> { - verify_script_with_flags(script, index, amount, spending_tx, bitcoinconsensus::VERIFY_ALL_PRE_TAPROOT) + verify_script_with_flags( + script, + index, + amount, + spending_tx, + bitcoinconsensus::VERIFY_ALL_PRE_TAPROOT, + ) } /// Verifies spend of an input script. diff --git a/bitcoin/src/merkle_tree/block.rs b/bitcoin/src/merkle_tree/block.rs index 8274e9be1..fbd6f92ff 100644 --- a/bitcoin/src/merkle_tree/block.rs +++ b/bitcoin/src/merkle_tree/block.rs @@ -513,18 +513,13 @@ impl std::error::Error for MerkleBlockError { #[cfg(test)] mod tests { - use super::*; + #[cfg(feature = "rand-std")] + use {crate::merkle_tree, core::cmp, secp256k1::rand::prelude::*}; + use super::*; use crate::consensus::encode; use crate::hash_types::Txid; - use crate::hex::{FromHex, test_hex_unwrap as hex}; - - #[cfg(feature = "rand-std")] - use { - core::cmp, - secp256k1::rand::prelude::*, - crate::merkle_tree, - }; + use crate::hex::{test_hex_unwrap as hex, FromHex}; #[cfg(feature = "rand-std")] macro_rules! pmt_tests { diff --git a/bitcoin/src/p2p/message.rs b/bitcoin/src/p2p/message.rs index 829e12114..57aa6f370 100644 --- a/bitcoin/src/p2p/message.rs +++ b/bitcoin/src/p2p/message.rs @@ -311,9 +311,7 @@ impl RawNetworkMessage { } /// Consumes the [RawNetworkMessage] instance and returns the inner payload. - pub fn into_payload(self) -> NetworkMessage { - self.payload - } + pub fn into_payload(self) -> NetworkMessage { self.payload } /// The actual message data pub fn payload(&self) -> &NetworkMessage { &self.payload } diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index 2a52157ed..912ace246 100644 --- a/hashes/src/internal_macros.rs +++ b/hashes/src/internal_macros.rs @@ -171,9 +171,11 @@ macro_rules! hash_type { pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) } /// Copies a byte slice into a hash object. - pub fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result { + pub fn from_slice( + sl: &[u8], + ) -> $crate::_export::_core::result::Result { if sl.len() != $bits / 8 { - Err(FromSliceError{expected: $bits / 8, got: sl.len()}) + Err(FromSliceError { expected: $bits / 8, got: sl.len() }) } else { let mut ret = [0; $bits / 8]; ret.copy_from_slice(sl); @@ -222,9 +224,7 @@ macro_rules! hash_type { /// An all zeros hash is a made up construct because there is not a known input that can create /// it, however it is used in various places in Bitcoin e.g., the Bitcoin genesis block's /// previous blockhash and the coinbase transaction's outpoint txid. - pub const fn all_zeros() -> Self { - Hash::internal_new([0x00; $bits / 8]) - } + pub const fn all_zeros() -> Self { Hash::internal_new([0x00; $bits / 8]) } } #[cfg(feature = "schemars")] diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 0678f3dab..adbba8253 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -57,14 +57,12 @@ impl Hash { pub fn engine() -> HashEngine { T::engine() } /// Produces a hash from the current state of a given engine. - pub fn from_engine(e: HashEngine) -> Hash { - from_engine(e) - } + pub fn from_engine(e: HashEngine) -> Hash { from_engine(e) } /// Copies a byte slice into a hash object. pub fn from_slice(sl: &[u8]) -> Result, FromSliceError> { if sl.len() != 32 { - Err(FromSliceError{expected: 32, got: sl.len()}) + Err(FromSliceError { expected: 32, got: sl.len() }) } else { let mut ret = [0; 32]; ret.copy_from_slice(sl); @@ -102,18 +100,14 @@ impl Hash { pub fn as_byte_array(&self) -> &[u8; 32] { &self.0 } /// Constructs a hash from the underlying byte array. - pub fn from_byte_array(bytes: [u8; 32]) -> Self { - Self::internal_new(bytes) - } + pub fn from_byte_array(bytes: [u8; 32]) -> Self { Self::internal_new(bytes) } /// Returns an all zero hash. /// /// An all zeros hash is a made up construct because there is not a known input that can create /// it, however it is used in various places in Bitcoin e.g., the Bitcoin genesis block's /// previous blockhash and the coinbase transaction's outpoint txid. - pub fn all_zeros() -> Self { - Hash::internal_new([0x00; 32]) - } + pub fn all_zeros() -> Self { Hash::internal_new([0x00; 32]) } } impl Copy for Hash {}