What changed, and why it matters
This commit is a routine automated code-formatting run by the rustfmt tool. It only changes whitespace, import order, line breaks, and brace placement. There are no functional changes, bug fixes, or security-related alterations.
No action required; this is a non-functional formatting commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff consists entirely of rustfmt style changes across 12 Rust source files: collapsing/expanding import lists, reordering use statements, reformatting function bodies to single-line where they fit, adding/removing blank lines, and rewrapping macro invocations and test assertions. No logic, API, or behavior changes are present.
Changed components
Inspect captured patch +56 / −69
diff --git a/bitcoin/src/bip152.rs b/bitcoin/src/bip152.rs
index 94951125..cf4ff313 100644
--- a/bitcoin/src/bip152.rs
+++ b/bitcoin/src/bip152.rs
@@ -17,9 +17,7 @@ use internals::ToU64 as _;
use io::{BufRead, Write};
use crate::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
-use crate::internal_macros::{
- self, impl_array_newtype, impl_array_newtype_stringify,
-};
+use crate::internal_macros::{self, impl_array_newtype, impl_array_newtype_stringify};
use crate::prelude::Vec;
use crate::transaction::TxIdentifier;
use crate::{block, consensus, Block, BlockChecked, BlockHash, Transaction};
diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs
index c495b59b..fda65186 100644
--- a/bitcoin/src/bip158.rs
+++ b/bitcoin/src/bip158.rs
@@ -50,10 +50,10 @@ use io::{BufRead, Write};
use crate::block::{Block, BlockHash, Checked};
use crate::consensus::{ReadExt, WriteExt};
+use crate::internal_macros;
use crate::prelude::{BTreeSet, Borrow, Vec};
use crate::script::{Script, ScriptExt as _};
use crate::transaction::OutPoint;
-use crate::internal_macros;
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
const P: u8 = 19;
diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs
index 4fdc29b7..59930071 100644
--- a/bitcoin/src/bip32.rs
+++ b/bitcoin/src/bip32.rs
@@ -16,9 +16,9 @@ use internals::write_err;
use secp256k1::Secp256k1;
use crate::crypto::key::{CompressedPublicKey, Keypair, PrivateKey, XOnlyPublicKey};
+use crate::internal_macros;
use crate::network::NetworkKind;
use crate::prelude::{String, Vec};
-use crate::internal_macros;
/// Version bytes for extended public keys on the Bitcoin network.
const VERSION_BYTES_MAINNET_PUBLIC: [u8; 4] = [0x04, 0x88, 0xB2, 0x1E];
diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs
index 4c62b917..263f845f 100644
--- a/bitcoin/src/blockdata/block.rs
+++ b/bitcoin/src/blockdata/block.rs
@@ -19,13 +19,13 @@ use super::transaction::Coinbase;
use super::Weight;
use crate::consensus::encode::WriteExt as _;
use crate::consensus::{encode, Decodable, Encodable};
+use crate::internal_macros;
use crate::merkle_tree::{MerkleNode as _, TxMerkleNode, WitnessMerkleNode};
use crate::network::Params;
use crate::pow::{Target, Work};
use crate::prelude::Vec;
use crate::script::{self, ScriptExt as _};
use crate::transaction::{Transaction, TransactionExt as _, Wtxid};
-use crate::internal_macros;
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
@@ -41,7 +41,15 @@ pub type BlockInterval = BlockHeightInterval;
internal_macros::impl_hashencode!(BlockHash);
-internal_macros::impl_consensus_encoding!(Header, version, prev_blockhash, merkle_root, time, bits, nonce);
+internal_macros::impl_consensus_encoding!(
+ Header,
+ version,
+ prev_blockhash,
+ merkle_root,
+ time,
+ bits,
+ nonce
+);
internal_macros::define_extension_trait! {
/// Extension functionality for the [`Header`] type.
diff --git a/bitcoin/src/blockdata/script/owned.rs b/bitcoin/src/blockdata/script/owned.rs
index 818c27f7..f6c18d02 100644
--- a/bitcoin/src/blockdata/script/owned.rs
+++ b/bitcoin/src/blockdata/script/owned.rs
@@ -8,7 +8,6 @@ use internals::ToU64 as _;
use secp256k1::{Secp256k1, Verification};
use super::{opcode_to_verify, Builder, Instruction, PushBytes, ScriptBuf, ScriptExtPriv as _};
-use crate::consensus;
use crate::key::{
PubkeyHash, PublicKey, TapTweak, TweakedPublicKey, UntweakedPublicKey, WPubkeyHash,
};
@@ -19,7 +18,7 @@ use crate::script::witness_program::{WitnessProgram, P2A_PROGRAM};
use crate::script::witness_version::WitnessVersion;
use crate::script::{self, ScriptHash, WScriptHash};
use crate::taproot::TapNodeHash;
-use crate::internal_macros;
+use crate::{consensus, internal_macros};
internal_macros::define_extension_trait! {
/// Extension functionality for the [`ScriptBuf`] type.
diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs
index 3de3defa..49a45a7c 100644
--- a/bitcoin/src/pow.rs
+++ b/bitcoin/src/pow.rs
@@ -14,8 +14,8 @@ use units::parse::{self, ParseIntError, PrefixedHexError, UnprefixedHexError};
use crate::block::{BlockHash, Header};
use crate::consensus::encode::{self, Decodable, Encodable};
-use crate::network::Params;
use crate::internal_macros;
+use crate::network::Params;
#[rustfmt::skip] // Keep public re-exports separate.
#[doc(inline)]
diff --git a/internals/src/const_casts.rs b/internals/src/const_casts.rs
index 6e38dd03..03ca18da 100644
--- a/internals/src/const_casts.rs
+++ b/internals/src/const_casts.rs
@@ -6,21 +6,13 @@
//! clear while maintaining compile-time evaluation capabilities.
/// Converts `u16` to `u64`
-pub const fn u16_to_u64(value: u16) -> u64 {
- value as u64
-}
+pub const fn u16_to_u64(value: u16) -> u64 { value as u64 }
/// Converts `u32` to `u64`
-pub const fn u32_to_u64(value: u32) -> u64 {
- value as u64
-}
+pub const fn u32_to_u64(value: u32) -> u64 { value as u64 }
/// Converts `i16` to `i64`
-pub const fn i16_to_i64(value: i16) -> i64 {
- value as i64
-}
+pub const fn i16_to_i64(value: i16) -> i64 { value as i64 }
/// Converts `u16` to `u32`
-pub const fn u16_to_u32(value: u16) -> u32 {
- value as u32
-}
\ No newline at end of file
+pub const fn u16_to_u32(value: u16) -> u32 { value as u32 }
diff --git a/p2p/examples/handshake.rs b/p2p/examples/handshake.rs
index cbf9fbc0..77aadf5a 100644
--- a/p2p/examples/handshake.rs
+++ b/p2p/examples/handshake.rs
@@ -4,12 +4,13 @@ use std::time::{SystemTime, UNIX_EPOCH};
use std::{env, process};
use bitcoin::consensus::{encode, Decodable};
+use bitcoin_p2p_messages::message_network::{ClientSoftwareVersion, UserAgent, UserAgentVersion};
use bitcoin_p2p_messages::{
self, address, message, message_network, Magic, ProtocolVersion, ServiceFlags,
};
-use bitcoin_p2p_messages::message_network::{ClientSoftwareVersion, UserAgent, UserAgentVersion};
-const SOFTWARE_VERSION: ClientSoftwareVersion = ClientSoftwareVersion::SemVer { major: 0, minor: 1, revision: 0 };
+const SOFTWARE_VERSION: ClientSoftwareVersion =
+ ClientSoftwareVersion::SemVer { major: 0, minor: 1, revision: 0 };
const USER_AGENT_VERSION: UserAgentVersion = UserAgentVersion::new(SOFTWARE_VERSION);
const SOFTWARE_NAME: &str = "rust-client";
diff --git a/p2p/src/address.rs b/p2p/src/address.rs
index 82a71571..c8bfe18a 100644
--- a/p2p/src/address.rs
+++ b/p2p/src/address.rs
@@ -37,7 +37,7 @@ impl Address {
};
Address { address, port, services }
}
-
+
/// Build an useless address that cannot be connected to. One may find this desirable if it is
/// known the data will be ignored by the recipient.
pub const fn useless() -> Address {
diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs
index 4cf5620a..b9410183 100644
--- a/p2p/src/lib.rs
+++ b/p2p/src/lib.rs
@@ -94,15 +94,11 @@ impl ProtocolVersion {
impl ProtocolVersion {
/// Construct a protocol version that is not well-known.
- pub fn from_nonstandard(version: u32) -> Self {
- Self(version)
- }
+ pub fn from_nonstandard(version: u32) -> Self { Self(version) }
}
impl From<ProtocolVersion> for u32 {
- fn from(version: ProtocolVersion) -> Self {
- version.0
- }
+ fn from(version: ProtocolVersion) -> Self { version.0 }
}
impl Encodable for ProtocolVersion {
diff --git a/p2p/src/message_network.rs b/p2p/src/message_network.rs
index d07e19fa..d895b3fc 100644
--- a/p2p/src/message_network.rs
+++ b/p2p/src/message_network.rs
@@ -133,9 +133,7 @@ impl UserAgent {
/// Build a user agent, ignoring BIP-14 recommendations.
pub fn from_nonstandard<S: ToString>(agent: S) -> Self {
- Self {
- user_agent: agent.to_string()
- }
+ Self { user_agent: agent.to_string() }
}
/// Add a client to the user agent string. Examples may include the name of a wallet software.
@@ -144,7 +142,11 @@ impl UserAgent {
///
/// If the client name contains one of: `/ ( ) :` or the user agent exceeds 256 characters.
#[must_use]
- pub fn add_client<S: AsRef<str>>(mut self, client_name: S, client_version: UserAgentVersion) -> Self {
+ pub fn add_client<S: AsRef<str>>(
+ mut self,
+ client_name: S,
+ client_version: UserAgentVersion,
+ ) -> Self {
let parsed_name = client_name.as_ref();
Self::panic_invalid_chars(parsed_name);
let agent = format!("{parsed_name}:{client_version}/");
@@ -155,15 +157,11 @@ impl UserAgent {
}
impl std::fmt::Display for UserAgent {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- self.user_agent.fmt(f)
- }
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.user_agent.fmt(f) }
}
impl From<UserAgent> for String {
- fn from(agent: UserAgent) -> Self {
- agent.user_agent
- }
+ fn from(agent: UserAgent) -> Self { agent.user_agent }
}
/// A software version field for inclusion in a user agent specified by BIP-14.
@@ -176,10 +174,7 @@ pub struct UserAgentVersion {
impl UserAgentVersion {
/// Create a user agent client version associated with a name.
pub const fn new(software_version: ClientSoftwareVersion) -> Self {
- Self {
- version: software_version,
- comments: None,
- }
+ Self { version: software_version, comments: None }
}
/// Add a comment to the version. Typical comments describe the operating system or platform
@@ -199,8 +194,8 @@ impl UserAgentVersion {
let semi_colon_delimeter = format!("; {parsed_comment}");
comment.push_str(&semi_colon_delimeter);
self.comments = Some(comment);
- },
- None => self.comments = Some(parsed_comment.to_string())
+ }
+ None => self.comments = Some(parsed_comment.to_string()),
}
self
}
@@ -237,18 +232,14 @@ pub enum ClientSoftwareVersion {
mm: u8,
/// The day
dd: u8,
- }
+ },
}
impl std::fmt::Display for ClientSoftwareVersion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
- Self::Date { yyyy, mm, dd } => {
- format!("{yyyy}{mm:02}{dd:02}").fmt(f)
- },
- Self::SemVer { major, minor, revision } => {
- format!("{major}.{minor}.{revision}").fmt(f)
- }
+ Self::Date { yyyy, mm, dd } => format!("{yyyy}{mm:02}{dd:02}").fmt(f),
+ Self::SemVer { major, minor, revision } => format!("{major}.{minor}.{revision}").fmt(f),
}
}
}
@@ -359,11 +350,17 @@ mod tests {
assert_eq!(real_decode.timestamp, 1401217254);
// address decodes should be covered by Address tests
assert_eq!(real_decode.nonce, 16735069437859780935);
- assert_eq!(real_decode.user_agent, UserAgent::new("Satoshi", UserAgentVersion::new(ClientSoftwareVersion::SemVer {
- major: 0,
- minor: 9,
- revision: 99
- })));
+ assert_eq!(
+ real_decode.user_agent,
+ UserAgent::new(
+ "Satoshi",
+ UserAgentVersion::new(ClientSoftwareVersion::SemVer {
+ major: 0,
+ minor: 9,
+ revision: 99
+ })
+ )
+ );
assert_eq!(real_decode.start_height, 302892);
assert!(real_decode.relay);
@@ -420,7 +417,7 @@ mod tests {
let client_version = UserAgentVersion::new(ClientSoftwareVersion::SemVer {
major: 5,
minor: 12,
- revision: 0
+ revision: 0,
});
let user_agent = UserAgent::new(client_name, client_version);
assert_eq!("/Satoshi:5.12.0/", user_agent.to_string());
@@ -428,23 +425,20 @@ mod tests {
let wallet_version = UserAgentVersion::new(ClientSoftwareVersion::SemVer {
major: 0,
minor: 8,
- revision: 0
+ revision: 0,
});
let user_agent = user_agent.add_client(wallet_name, wallet_version);
assert_eq!("/Satoshi:5.12.0/bitcoin-qt:0.8.0/", user_agent.to_string());
let client_name = "BitcoinJ";
- let client_version = UserAgentVersion::new(ClientSoftwareVersion::Date {
- yyyy: 2011,
- mm: 1,
- dd: 28
- });
+ let client_version =
+ UserAgentVersion::new(ClientSoftwareVersion::Date { yyyy: 2011, mm: 1, dd: 28 });
let user_agent = UserAgent::new(client_name, client_version);
assert_eq!("/BitcoinJ:20110128/", user_agent.to_string());
let wallet_name = "Electrum";
let wallet_version = UserAgentVersion::new(ClientSoftwareVersion::SemVer {
major: 0,
minor: 9,
- revision: 0
+ revision: 0,
});
let wallet_version = wallet_version.push_comment("Ubuntu");
let wallet_version = wallet_version.push_comment("24");
@@ -459,7 +453,7 @@ mod tests {
let client_version = UserAgentVersion::new(ClientSoftwareVersion::SemVer {
major: 5,
minor: 12,
- revision: 0
+ revision: 0,
});
UserAgent::new(client_name, client_version);
}
diff --git a/units/src/lib.rs b/units/src/lib.rs
index 528ceee5..72acdc7d 100644
--- a/units/src/lib.rs
+++ b/units/src/lib.rs
@@ -34,7 +34,6 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
-
#[doc(hidden)]
pub mod _export {
/// A re-export of `core::*`.
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.