2024-09-08 automated rustfmt nightly

This commit is contained in:
Fmt Bot 2024-09-08 01:17:12 +00:00 committed by github-actions[bot]
parent 2c26dc4e57
commit 9a5ba9b6df
10 changed files with 31 additions and 16 deletions

View File

@ -47,7 +47,10 @@ pub const MAX_STACK_ELEMENT_SIZE: usize = 520;
/// How may blocks between halvings. /// How may blocks between halvings.
pub const SUBSIDY_HALVING_INTERVAL: u32 = 210_000; pub const SUBSIDY_HALVING_INTERVAL: u32 = 210_000;
/// Maximum allowed value for an integer in Script. /// Maximum allowed value for an integer in Script.
#[deprecated(since = "TBD", note = "This constant has ambiguous semantics. Please carefully check your intended use-case and define a new constant reflecting that.")] #[deprecated(
since = "TBD",
note = "This constant has ambiguous semantics. Please carefully check your intended use-case and define a new constant reflecting that."
)]
pub const MAX_SCRIPTNUM_VALUE: u32 = 0x80000000; // 2^31 pub const MAX_SCRIPTNUM_VALUE: u32 = 0x80000000; // 2^31
/// Number of blocks needed for an output from a coinbase transaction to be spendable. /// Number of blocks needed for an output from a coinbase transaction to be spendable.
pub const COINBASE_MATURITY: u32 = 100; pub const COINBASE_MATURITY: u32 = 100;

View File

@ -174,7 +174,8 @@ impl fmt::LowerHex for SerializedSignature {
fmt::LowerHex::fmt(&(**self).as_hex(), f) fmt::LowerHex::fmt(&(**self).as_hex(), f)
} }
} }
impl_to_hex_from_lower_hex!(SerializedSignature, |signature: &SerializedSignature| signature.len * 2); impl_to_hex_from_lower_hex!(SerializedSignature, |signature: &SerializedSignature| signature.len
* 2);
impl fmt::UpperHex for SerializedSignature { impl fmt::UpperHex for SerializedSignature {
#[inline] #[inline]

View File

@ -22,6 +22,7 @@ pub mod message_network;
use core::str::FromStr; use core::str::FromStr;
use core::{fmt, ops}; use core::{fmt, ops};
use hex::FromHex; use hex::FromHex;
use internals::{debug_from_display, impl_to_hex_from_lower_hex, write_err}; use internals::{debug_from_display, impl_to_hex_from_lower_hex, write_err};
use io::{BufRead, Write}; use io::{BufRead, Write};
@ -122,7 +123,8 @@ impl ServiceFlags {
impl fmt::LowerHex for ServiceFlags { impl fmt::LowerHex for ServiceFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
} }
impl_to_hex_from_lower_hex!(ServiceFlags, |service_flags: &ServiceFlags| 16 - service_flags.0.leading_zeros() as usize / 4); impl_to_hex_from_lower_hex!(ServiceFlags, |service_flags: &ServiceFlags| 16
- service_flags.0.leading_zeros() as usize / 4);
impl fmt::UpperHex for ServiceFlags { impl fmt::UpperHex for ServiceFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }

View File

@ -7,6 +7,7 @@
use core::ops::{Add, Div, Mul, Not, Rem, Shl, Shr, Sub}; use core::ops::{Add, Div, Mul, Not, Rem, Shl, Shr, Sub};
use core::{cmp, fmt}; use core::{cmp, fmt};
use internals::impl_to_hex_from_lower_hex; use internals::impl_to_hex_from_lower_hex;
use io::{BufRead, Write}; use io::{BufRead, Write};
#[cfg(all(test, mutate))] #[cfg(all(test, mutate))]

View File

@ -109,9 +109,7 @@ mod message_signing {
} }
/// Creates a `MessageSignature` from a fixed-length array. /// Creates a `MessageSignature` from a fixed-length array.
pub fn from_byte_array( pub fn from_byte_array(bytes: &[u8; 65]) -> Result<MessageSignature, secp256k1::Error> {
bytes: &[u8; 65],
) -> Result<MessageSignature, secp256k1::Error> {
// We just check this here so we can safely subtract further. // We just check this here so we can safely subtract further.
if bytes[0] < 27 { if bytes[0] < 27 {
return Err(secp256k1::Error::InvalidRecoveryId); return Err(secp256k1::Error::InvalidRecoveryId);

View File

@ -79,8 +79,11 @@ where
let t = Hmac::from_engine(hmac_engine); let t = Hmac::from_engine(hmac_engine);
let start_index = (counter as usize - 1) * T::Bytes::LEN; let start_index = (counter as usize - 1) * T::Bytes::LEN;
// Last block might not take full hash length. // Last block might not take full hash length.
let end_index = let end_index = if counter == (total_blocks as u8) {
if counter == (total_blocks as u8) { okm.len() } else { counter as usize * T::Bytes::LEN }; okm.len()
} else {
counter as usize * T::Bytes::LEN
};
okm[start_index..end_index].copy_from_slice(&t.as_ref()[0..(end_index - start_index)]); okm[start_index..end_index].copy_from_slice(&t.as_ref()[0..(end_index - start_index)]);

View File

@ -274,7 +274,7 @@ pub trait Hash:
+ convert::AsRef<[u8]> + convert::AsRef<[u8]>
{ {
/// The byte array that represents the hash internally. /// The byte array that represents the hash internally.
type Bytes: hex::FromHex + Copy + IsByteArray /* <LEN={Self::LEN}> is still unsupported by Rust */; type Bytes: hex::FromHex + Copy + IsByteArray;
/// Length of the hash, in bytes. /// Length of the hash, in bytes.
const LEN: usize = Self::Bytes::LEN; const LEN: usize = Self::Bytes::LEN;
@ -309,9 +309,9 @@ impl<const N: usize> IsByteArray for [u8; N] {
mod sealed { mod sealed {
#[doc(hidden)] #[doc(hidden)]
pub trait IsByteArray { } pub trait IsByteArray {}
impl<const N: usize> IsByteArray for [u8; N] { } impl<const N: usize> IsByteArray for [u8; N] {}
} }
/// Attempted to create a hash from an invalid length slice. /// Attempted to create a hash from an invalid length slice.

View File

@ -227,7 +227,5 @@ macro_rules! impl_to_hex_from_lower_hex {
#[macro_export] #[macro_export]
#[cfg(not(feature = "alloc"))] #[cfg(not(feature = "alloc"))]
macro_rules! impl_to_hex_from_lower_hex { macro_rules! impl_to_hex_from_lower_hex {
($t:ident, $hex_len_fn:expr) => { ($t:ident, $hex_len_fn:expr) => {};
};
} }

View File

@ -3,6 +3,7 @@
//! Proof-of-work related integer types. //! Proof-of-work related integer types.
use core::fmt; use core::fmt;
use internals::impl_to_hex_from_lower_hex; use internals::impl_to_hex_from_lower_hex;
/// Encoding of 256-bit target as 32-bit float. /// Encoding of 256-bit target as 32-bit float.
@ -35,7 +36,11 @@ impl fmt::LowerHex for CompactTarget {
#[inline] #[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
} }
impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| 8 - compact_target.0.leading_zeros() as usize / 4); impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| 8 - compact_target
.0
.leading_zeros()
as usize
/ 4);
impl fmt::UpperHex for CompactTarget { impl fmt::UpperHex for CompactTarget {
#[inline] #[inline]

View File

@ -16,6 +16,7 @@
//! [BIP-125]: <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki> //! [BIP-125]: <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki>
use core::fmt; use core::fmt;
use internals::impl_to_hex_from_lower_hex; use internals::impl_to_hex_from_lower_hex;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -23,6 +24,7 @@ use serde::{Deserialize, Serialize};
use units::locktime::relative::TimeOverflowError; use units::locktime::relative::TimeOverflowError;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
use units::parse::{self, PrefixedHexError, UnprefixedHexError}; use units::parse::{self, PrefixedHexError, UnprefixedHexError};
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
use crate::locktime::relative; use crate::locktime::relative;
@ -219,7 +221,9 @@ impl fmt::Display for Sequence {
impl fmt::LowerHex for Sequence { impl fmt::LowerHex for Sequence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
} }
impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| 8 - sequence.0.leading_zeros() as usize / 4); impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| 8 - sequence.0.leading_zeros()
as usize
/ 4);
impl fmt::UpperHex for Sequence { impl fmt::UpperHex for Sequence {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) } fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }