Merge rust-bitcoin/rust-bitcoin#2871: Automated nightly rustfmt (2024-06-16)

4745b55cae 2024-06-16 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:
    ACK 4745b55cae

Tree-SHA512: 1781948d9cb4946c92920007e0af4daf8c144743f25b13d8da4984dc2da35c7def0170b708a87c41cd4263b471f9d34fe6c3ac59daf66a0e3c1f1a3fcb3a3397
This commit is contained in:
Andrew Poelstra 2024-06-16 13:50:12 +00:00
commit 406e3486ab
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
5 changed files with 21 additions and 28 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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 }

View File

@ -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<Hash, FromSliceError> {
pub fn from_slice(
sl: &[u8],
) -> $crate::_export::_core::result::Result<Hash, FromSliceError> {
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")]

View File

@ -57,14 +57,12 @@ impl<T: Tag> Hash<T> {
pub fn engine() -> HashEngine { T::engine() }
/// Produces a hash from the current state of a given engine.
pub fn from_engine(e: HashEngine) -> Hash<T> {
from_engine(e)
}
pub fn from_engine(e: HashEngine) -> Hash<T> { from_engine(e) }
/// Copies a byte slice into a hash object.
pub fn from_slice(sl: &[u8]) -> Result<Hash<T>, 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<T: Tag> Hash<T> {
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<T: Tag> Copy for Hash<T> {}