What changed, and why it matters
This commit is an automated code-formatting run by rustfmt. It only changes whitespace, line breaks, import ordering, and other stylistic details. No program logic, security checks, or behavior were altered.
No security action needed. This is a routine formatting commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows pure formatting changes across 11 Rust source files in the rust-bitcoin p2p and primitives crates. All modifications are whitespace/line-wrapping adjustments, reordering of use statements, and adding/removing blank lines. There are no semantic code changes, no modifications to parsing/validation logic, and no changes to cryptographic or network handling code.
Changed components
fuzz/fuzz_targets/p2p/arbitrary_addrv2.rsfuzz/fuzz_targets/p2p/deserialize_addrv2.rsp2p/src/address.rsp2p/src/lib.rsp2p/src/message.rsp2p/src/message_blockdata.rsp2p/src/message_bloom.rsp2p/src/message_compact_blocks.rsp2p/src/message_filter.rsp2p/src/message_network.rsprimitives/src/merkle_tree.rsInspect captured patch +110 / −52
diff --git a/fuzz/fuzz_targets/p2p/arbitrary_addrv2.rs b/fuzz/fuzz_targets/p2p/arbitrary_addrv2.rs
index 3bde4f2c..31f4fa56 100644
--- a/fuzz/fuzz_targets/p2p/arbitrary_addrv2.rs
+++ b/fuzz/fuzz_targets/p2p/arbitrary_addrv2.rs
@@ -1,5 +1,6 @@
use std::convert::TryFrom;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
+
use arbitrary::{Arbitrary, Unstructured};
use honggfuzz::fuzz;
use p2p::address::AddrV2;
@@ -11,17 +12,26 @@ fn do_test(data: &[u8]) {
if let Ok(addr_v2) = a {
if let Ok(ip_addr) = IpAddr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr);
- assert_eq!(addr_v2, round_trip, "AddrV2 -> IpAddr -> AddrV2 should round-trip correctly");
+ assert_eq!(
+ addr_v2, round_trip,
+ "AddrV2 -> IpAddr -> AddrV2 should round-trip correctly"
+ );
}
if let Ok(ip_addr) = Ipv4Addr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr);
- assert_eq!(addr_v2, round_trip, "AddrV2 -> Ipv4Addr -> AddrV2 should round-trip correctly");
+ assert_eq!(
+ addr_v2, round_trip,
+ "AddrV2 -> Ipv4Addr -> AddrV2 should round-trip correctly"
+ );
}
if let Ok(ip_addr) = Ipv6Addr::try_from(addr_v2.clone()) {
let round_trip: AddrV2 = AddrV2::from(ip_addr);
- assert_eq!(addr_v2, round_trip, "AddrV2 -> Ipv6Addr -> AddrV2 should round-trip correctly");
+ assert_eq!(
+ addr_v2, round_trip,
+ "AddrV2 -> Ipv6Addr -> AddrV2 should round-trip correctly"
+ );
}
}
}
diff --git a/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs b/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
index 712aa096..6f4577dc 100644
--- a/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
+++ b/fuzz/fuzz_targets/p2p/deserialize_addrv2.rs
@@ -1,8 +1,7 @@
use honggfuzz::fuzz;
fn do_test(data: &[u8]) {
- let _: Result<p2p::address::AddrV2, _> =
- bitcoin::consensus::encode::deserialize(data);
+ let _: Result<p2p::address::AddrV2, _> = bitcoin::consensus::encode::deserialize(data);
}
fn main() {
diff --git a/p2p/src/address.rs b/p2p/src/address.rs
index 3efa8328..a9cb782e 100644
--- a/p2p/src/address.rs
+++ b/p2p/src/address.rs
@@ -9,9 +9,9 @@ use alloc::vec;
use alloc::vec::Vec;
use core::{fmt, iter};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
+
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use io::{BufRead, Read, Write};
@@ -448,8 +448,28 @@ impl std::error::Error for AddrV2ToIpv6AddrError {}
impl<'a> Arbitrary<'a> for Address {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
let socket_addr = match bool::arbitrary(u)? {
- true => SocketAddr::new(IpAddr::V4(Ipv4Addr::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?)), u.arbitrary()?),
- false => SocketAddr::new(IpAddr::V6(Ipv6Addr::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?)), u.arbitrary()?)
+ true => SocketAddr::new(
+ IpAddr::V4(Ipv4Addr::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ )),
+ u.arbitrary()?,
+ ),
+ false => SocketAddr::new(
+ IpAddr::V6(Ipv6Addr::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ )),
+ u.arbitrary()?,
+ ),
};
Ok(Address::new(&socket_addr, u.arbitrary()?))
@@ -459,12 +479,35 @@ impl<'a> Arbitrary<'a> for Address {
impl<'a> Arbitrary<'a> for AddrV2 {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
match u.int_in_range(0..=5)? {
- 0 => Ok(AddrV2::Ipv4(Ipv4Addr::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?))),
- 1 => Ok(AddrV2::Ipv6(Ipv6Addr::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?))),
+ 0 => Ok(AddrV2::Ipv4(Ipv4Addr::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ ))),
+ 1 => Ok(AddrV2::Ipv6(Ipv6Addr::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ ))),
2 => Ok(AddrV2::TorV3(u.arbitrary()?)),
3 => Ok(AddrV2::I2p(u.arbitrary()?)),
- 4 => Ok(AddrV2::Cjdns(Ipv6Addr::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?))),
- _ => Ok(AddrV2::Unknown(u.arbitrary()?, Vec::<u8>::arbitrary(u)?))
+ 4 => Ok(AddrV2::Cjdns(Ipv6Addr::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ ))),
+ _ => Ok(AddrV2::Unknown(u.arbitrary()?, Vec::<u8>::arbitrary(u)?)),
}
}
}
@@ -472,11 +515,11 @@ impl<'a> Arbitrary<'a> for AddrV2 {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for AddrV2Message {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(AddrV2Message{
+ Ok(AddrV2Message {
time: u.arbitrary()?,
services: u.arbitrary()?,
addr: u.arbitrary()?,
- port: u.arbitrary()?
+ port: u.arbitrary()?,
})
}
}
diff --git a/p2p/src/lib.rs b/p2p/src/lib.rs
index 299a1b1f..c839e3ab 100644
--- a/p2p/src/lib.rs
+++ b/p2p/src/lib.rs
@@ -39,9 +39,9 @@ use alloc::string::String;
use core::borrow::{Borrow, BorrowMut};
use core::str::FromStr;
use core::{fmt, ops};
+
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::consensus::encode::{self, Decodable, Encodable};
use bitcoin::network::{Network, Params, TestnetVersion};
use hex::FromHex;
@@ -481,9 +481,7 @@ impl<'a> Arbitrary<'a> for ServiceFlags {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for Magic {
- fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(Magic(u.arbitrary()?))
- }
+ fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> { Ok(Magic(u.arbitrary()?)) }
}
#[cfg(test)]
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index effebc31..e1294416 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -10,11 +10,10 @@ use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
+use core::{cmp, fmt};
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use core::{cmp, fmt};
-
use bitcoin::block::HeaderExt;
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use bitcoin::merkle_tree::MerkleBlock;
@@ -817,7 +816,7 @@ impl Decodable for CheckedData {
expected: expected_checksum,
actual: checksum,
}
- .into())
+ .into())
} else {
Ok(CheckedData { data, checksum })
}
diff --git a/p2p/src/message_blockdata.rs b/p2p/src/message_blockdata.rs
index 4265c1f1..72ef0fbd 100644
--- a/p2p/src/message_blockdata.rs
+++ b/p2p/src/message_blockdata.rs
@@ -6,9 +6,9 @@
//! Bitcoin data (blocks and transactions) around.
use alloc::vec::Vec;
+
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::block::BlockHash;
use bitcoin::consensus::encode::{self, Decodable, Encodable};
use bitcoin::transaction::{Txid, Wtxid};
@@ -135,14 +135,22 @@ impl_consensus_encoding!(GetHeadersMessage, version, locator_hashes, stop_hash);
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetHeadersMessage {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetHeadersMessage{version: u.arbitrary()?, locator_hashes: Vec::<BlockHash>::arbitrary(u)?, stop_hash: u.arbitrary()?})
+ Ok(GetHeadersMessage {
+ version: u.arbitrary()?,
+ locator_hashes: Vec::<BlockHash>::arbitrary(u)?,
+ stop_hash: u.arbitrary()?,
+ })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetBlocksMessage {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetBlocksMessage{version: u.arbitrary()?, locator_hashes: Vec::<BlockHash>::arbitrary(u)?, stop_hash: u.arbitrary()?})
+ Ok(GetBlocksMessage {
+ version: u.arbitrary()?,
+ locator_hashes: Vec::<BlockHash>::arbitrary(u)?,
+ stop_hash: u.arbitrary()?,
+ })
}
}
@@ -157,10 +165,7 @@ impl<'a> Arbitrary<'a> for Inventory {
4 => Ok(Inventory::WTx(u.arbitrary()?)),
5 => Ok(Inventory::WitnessTransaction(u.arbitrary()?)),
6 => Ok(Inventory::WitnessBlock(u.arbitrary()?)),
- _ => Ok(Inventory::Unknown {
- inv_type: u.arbitrary()?,
- hash: u.arbitrary()?
- })
+ _ => Ok(Inventory::Unknown { inv_type: u.arbitrary()?, hash: u.arbitrary()? }),
}
}
}
diff --git a/p2p/src/message_bloom.rs b/p2p/src/message_bloom.rs
index d6daadee..4722949c 100644
--- a/p2p/src/message_bloom.rs
+++ b/p2p/src/message_bloom.rs
@@ -8,7 +8,6 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt};
use io::{BufRead, Write};
@@ -77,7 +76,7 @@ impl<'a> Arbitrary<'a> for BloomFlags {
match u.int_in_range(0..=2)? {
0 => Ok(BloomFlags::None),
1 => Ok(BloomFlags::All),
- _ => Ok(BloomFlags::PubkeyOnly)
+ _ => Ok(BloomFlags::PubkeyOnly),
}
}
}
@@ -85,14 +84,14 @@ impl<'a> Arbitrary<'a> for BloomFlags {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for FilterAdd {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(FilterAdd{ data: Vec::<u8>::arbitrary(u)? })
+ Ok(FilterAdd { data: Vec::<u8>::arbitrary(u)? })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for FilterLoad {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(FilterLoad{
+ Ok(FilterLoad {
filter: Vec::<u8>::arbitrary(u)?,
hash_funcs: u.arbitrary()?,
tweak: u.arbitrary()?,
diff --git a/p2p/src/message_compact_blocks.rs b/p2p/src/message_compact_blocks.rs
index cee25810..af8f141e 100644
--- a/p2p/src/message_compact_blocks.rs
+++ b/p2p/src/message_compact_blocks.rs
@@ -5,7 +5,6 @@
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::bip152;
use crate::consensus::impl_consensus_encoding;
@@ -52,27 +51,27 @@ impl_consensus_encoding!(BlockTxn, transactions);
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for SendCmpct {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(SendCmpct{ send_compact: u.arbitrary()?, version: u.arbitrary()? })
+ Ok(SendCmpct { send_compact: u.arbitrary()?, version: u.arbitrary()? })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for CmpctBlock {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(CmpctBlock{ compact_block: u.arbitrary()? })
+ Ok(CmpctBlock { compact_block: u.arbitrary()? })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetBlockTxn {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetBlockTxn{ txs_request: u.arbitrary()? })
+ Ok(GetBlockTxn { txs_request: u.arbitrary()? })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for BlockTxn {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(BlockTxn{ transactions: u.arbitrary()? })
+ Ok(BlockTxn { transactions: u.arbitrary()? })
}
}
diff --git a/p2p/src/message_filter.rs b/p2p/src/message_filter.rs
index 65dba191..434df752 100644
--- a/p2p/src/message_filter.rs
+++ b/p2p/src/message_filter.rs
@@ -8,7 +8,6 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-
use bitcoin::bip158::{FilterHash, FilterHeader};
use bitcoin::block::BlockHash;
use units::BlockHeight;
@@ -90,7 +89,7 @@ impl_consensus_encoding!(CFCheckpt, filter_type, stop_hash, filter_headers);
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetCFilters {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetCFilters{
+ Ok(GetCFilters {
filter_type: u.arbitrary()?,
start_height: u.arbitrary()?,
stop_hash: u.arbitrary()?,
@@ -101,7 +100,7 @@ impl<'a> Arbitrary<'a> for GetCFilters {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for CFilter {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(CFilter{
+ Ok(CFilter {
filter_type: u.arbitrary()?,
block_hash: u.arbitrary()?,
filter: Vec::<u8>::arbitrary(u)?,
@@ -112,7 +111,7 @@ impl<'a> Arbitrary<'a> for CFilter {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetCFHeaders {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetCFHeaders{
+ Ok(GetCFHeaders {
filter_type: u.arbitrary()?,
start_height: u.arbitrary()?,
stop_hash: u.arbitrary()?,
@@ -123,7 +122,7 @@ impl<'a> Arbitrary<'a> for GetCFHeaders {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for CFHeaders {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(CFHeaders{
+ Ok(CFHeaders {
filter_type: u.arbitrary()?,
stop_hash: u.arbitrary()?,
previous_filter_header: u.arbitrary()?,
@@ -135,18 +134,17 @@ impl<'a> Arbitrary<'a> for CFHeaders {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for GetCFCheckpt {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(GetCFCheckpt{ filter_type: u.arbitrary()?, stop_hash: u.arbitrary()? })
+ Ok(GetCFCheckpt { filter_type: u.arbitrary()?, stop_hash: u.arbitrary()? })
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for CFCheckpt {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(CFCheckpt{
+ Ok(CFCheckpt {
filter_type: u.arbitrary()?,
stop_hash: u.arbitrary()?,
filter_headers: Vec::<FilterHeader>::arbitrary(u)?,
})
}
}
-
diff --git a/p2p/src/message_network.rs b/p2p/src/message_network.rs
index 27626de5..5b22c6b0 100644
--- a/p2p/src/message_network.rs
+++ b/p2p/src/message_network.rs
@@ -7,11 +7,11 @@
use alloc::borrow::Cow;
use alloc::format;
-#[cfg(feature = "arbitrary")]
-use arbitrary::{Arbitrary, Unstructured};
use alloc::string::{String, ToString};
use alloc::vec::Vec;
+#[cfg(feature = "arbitrary")]
+use arbitrary::{Arbitrary, Unstructured};
use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt, WriteExt};
use hashes::sha256d;
use io::{BufRead, Write};
@@ -343,7 +343,7 @@ impl<'a> Arbitrary<'a> for ClientSoftwareVersion {
major: u.arbitrary()?,
minor: u.arbitrary()?,
revision: u.arbitrary()?,
- })
+ }),
}
}
}
@@ -365,7 +365,16 @@ impl<'a> Arbitrary<'a> for UserAgent {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for VersionMessage {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(VersionMessage::new(u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?, u.arbitrary()?))
+ Ok(VersionMessage::new(
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ u.arbitrary()?,
+ ))
}
}
@@ -380,7 +389,7 @@ impl<'a> Arbitrary<'a> for RejectReason {
4 => Ok(RejectReason::NonStandard),
5 => Ok(RejectReason::Dust),
6 => Ok(RejectReason::Fee),
- _ => Ok(RejectReason::Checkpoint)
+ _ => Ok(RejectReason::Checkpoint),
}
}
}
@@ -388,7 +397,7 @@ impl<'a> Arbitrary<'a> for RejectReason {
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for Reject {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
- Ok(Reject{
+ Ok(Reject {
message: u.arbitrary::<String>()?.into(),
ccode: u.arbitrary()?,
reason: u.arbitrary::<String>()?.into(),
diff --git a/primitives/src/merkle_tree.rs b/primitives/src/merkle_tree.rs
index b25d2768..e037644b 100644
--- a/primitives/src/merkle_tree.rs
+++ b/primitives/src/merkle_tree.rs
@@ -12,4 +12,3 @@
#[doc(inline)]
pub use crate::hash_types::{TxMerkleNode, TxMerkleNodeEncoder, WitnessMerkleNode};
-
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.