Skip to content

Commit 7bbb908

Browse files
committed
Merge rust-bitcoin#4634: Automated nightly rustfmt (2025-06-22)
c060285 2025-06-22 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: tcharding: ACK c060285 apoelstra: ACK c060285; successfully ran local tests Tree-SHA512: e0eed455b4641522fb1dbdcf57e51cc8328be9be63d01d21e4d4868ad8fe47f11ea449574e85986bbaa7d7dbed89c3d7bce66f84059440c0588c0bde58a36d92
2 parents 7af15ab + c060285 commit 7bbb908

File tree

12 files changed

+49
-39
lines changed

12 files changed

+49
-39
lines changed

bitcoin/src/bip32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ mod tests {
11791179
fn test_upperhex_formatting() {
11801180
let normal = Normal { index: 42 };
11811181
let hardened = Hardened { index: 42 };
1182-
1182+
11831183
assert_eq!(format!("{:X}", normal), "2A");
11841184
assert_eq!(format!("{:#X}", normal), "0x2A");
11851185

fuzz/fuzz_targets/bitcoin/p2p_address_roundtrip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::convert::TryFrom;
22
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
33

44
use bitcoin::consensus::Decodable;
5-
use p2p::address::AddrV2;
65
use honggfuzz::fuzz;
6+
use p2p::address::AddrV2;
77

88
fn do_test(data: &[u8]) {
99
if data.len() < 2 {

p2p/src/address.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use core::{fmt, iter};
99
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
1010

11+
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
1112
use io::{BufRead, Read, Write};
1213

13-
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
1414
use crate::ServiceFlags;
1515

1616
/// A message which can be sent on the Bitcoin network
@@ -206,7 +206,8 @@ impl Encodable for AddrV2 {
206206
network: u8,
207207
bytes: &[u8],
208208
) -> Result<usize, io::Error> {
209-
Ok(network.consensus_encode(w)? + crate::consensus::consensus_encode_with_size(bytes, w)?)
209+
Ok(network.consensus_encode(w)?
210+
+ crate::consensus::consensus_encode_with_size(bytes, w)?)
210211
}
211212
Ok(match *self {
212213
AddrV2::Ipv4(ref addr) => encode_addr(w, 1, &addr.octets())?,

p2p/src/consensus.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ pub(crate) fn consensus_encode_with_size<W: Write + ?Sized>(
99
}
1010

1111
pub(crate) fn parse_failed_error(msg: &'static str) -> bitcoin::consensus::encode::Error {
12-
bitcoin::consensus::encode::Error::Parse(bitcoin::consensus::encode::ParseError::ParseFailed(msg))
12+
bitcoin::consensus::encode::Error::Parse(bitcoin::consensus::encode::ParseError::ParseFailed(
13+
msg,
14+
))
1315
}
1416

1517
macro_rules! impl_consensus_encoding {

p2p/src/lib.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,26 @@
1616
#![allow(clippy::uninlined_format_args)] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
1717

1818
pub mod address;
19+
mod consensus;
1920
pub mod message;
2021
pub mod message_blockdata;
2122
pub mod message_bloom;
2223
pub mod message_compact_blocks;
2324
pub mod message_filter;
2425
pub mod message_network;
25-
mod consensus;
2626

2727
extern crate alloc;
2828

2929
use core::str::FromStr;
3030
use core::{fmt, ops};
31-
3231
use std::borrow::{Borrow, BorrowMut, ToOwned};
3332

33+
use bitcoin::consensus::encode::{self, Decodable, Encodable};
34+
use bitcoin::network::{Network, Params, TestnetVersion};
3435
use hex::FromHex;
3536
use internals::impl_to_hex_from_lower_hex;
3637
use io::{BufRead, Write};
3738

38-
use bitcoin::consensus::encode::{self, Decodable, Encodable};
39-
use bitcoin::network::{Network, Params, TestnetVersion};
40-
4139
#[rustfmt::skip]
4240
#[doc(inline)]
4341
pub use self::address::Address;
@@ -243,7 +241,9 @@ impl Magic {
243241
pub fn to_bytes(self) -> [u8; 4] { self.0 }
244242

245243
/// Returns the magic bytes for the network defined by `params`.
246-
pub fn from_params(params: impl AsRef<Params>) -> Option<Self> { params.as_ref().network.try_into().ok() }
244+
pub fn from_params(params: impl AsRef<Params>) -> Option<Self> {
245+
params.as_ref().network.try_into().ok()
246+
}
247247
}
248248

249249
impl FromStr for Magic {
@@ -409,9 +409,10 @@ impl std::error::Error for UnknownNetworkError {
409409

410410
#[cfg(test)]
411411
mod tests {
412-
use super::*;
413412
use bitcoin::consensus::encode::{deserialize, serialize};
414413

414+
use super::*;
415+
415416
#[test]
416417
fn serialize_deserialize() {
417418
assert_eq!(serialize(&Magic::BITCOIN), &[0xf9, 0xbe, 0xb4, 0xd9]);
@@ -430,7 +431,10 @@ mod tests {
430431
let magic: Magic = Network::Regtest.try_into().unwrap();
431432
assert_eq!(serialize(&magic), &[0xfa, 0xbf, 0xb5, 0xda]);
432433

433-
assert_eq!(deserialize::<Magic>(&[0xf9, 0xbe, 0xb4, 0xd9]).ok(), Network::Bitcoin.try_into().ok());
434+
assert_eq!(
435+
deserialize::<Magic>(&[0xf9, 0xbe, 0xb4, 0xd9]).ok(),
436+
Network::Bitcoin.try_into().ok()
437+
);
434438
assert_eq!(
435439
deserialize::<Magic>(&[0x0b, 0x11, 0x09, 0x07]).ok(),
436440
Network::Testnet(TestnetVersion::V3).try_into().ok()
@@ -439,11 +443,16 @@ mod tests {
439443
deserialize::<Magic>(&[0x1c, 0x16, 0x3f, 0x28]).ok(),
440444
Network::Testnet(TestnetVersion::V4).try_into().ok()
441445
);
442-
assert_eq!(deserialize::<Magic>(&[0x0a, 0x03, 0xcf, 0x40]).ok(), Network::Signet.try_into().ok());
443-
assert_eq!(deserialize::<Magic>(&[0xfa, 0xbf, 0xb5, 0xda]).ok(), Network::Regtest.try_into().ok());
446+
assert_eq!(
447+
deserialize::<Magic>(&[0x0a, 0x03, 0xcf, 0x40]).ok(),
448+
Network::Signet.try_into().ok()
449+
);
450+
assert_eq!(
451+
deserialize::<Magic>(&[0xfa, 0xbf, 0xb5, 0xda]).ok(),
452+
Network::Regtest.try_into().ok()
453+
);
444454
}
445455

446-
447456
#[test]
448457
fn service_flags_test() {
449458
let all = [

p2p/src/message.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
//! are used for (de)serializing Bitcoin objects for transmission on the network.
77
88
use core::{fmt, iter};
9-
use std::borrow::Cow;
9+
use std::borrow::{Cow, ToOwned};
1010
use std::boxed::Box;
11-
use std::borrow::ToOwned;
1211

12+
use bitcoin::consensus::encode::{self, CheckedData, Decodable, Encodable, ReadExt, WriteExt};
13+
use bitcoin::merkle_tree::MerkleBlock;
14+
use bitcoin::{block, transaction};
1315
use hashes::sha256d;
1416
use internals::ToU64 as _;
1517
use io::{BufRead, Write};
1618

17-
use bitcoin::consensus::encode::{self, CheckedData, Decodable, Encodable, ReadExt, WriteExt};
18-
use bitcoin::merkle_tree::MerkleBlock;
1919
use crate::address::{AddrV2Message, Address};
2020
use crate::consensus::impl_vec_wrapper;
2121
use crate::{
2222
message_blockdata, message_bloom, message_compact_blocks, message_filter, message_network,
2323
Magic,
2424
};
25-
use bitcoin::{block, transaction};
2625

2726
/// The maximum number of [super::message_blockdata::Inventory] items in an `inv` message.
2827
///
@@ -715,16 +714,16 @@ impl Decodable for V2NetworkMessage {
715714
mod test {
716715
use std::net::Ipv4Addr;
717716

718-
use hex_lit::hex;
719-
use units::BlockHeight;
720-
721-
use super::*;
722717
use bitcoin::bip152::BlockTransactionsRequest;
723718
use bitcoin::bip158::{FilterHash, FilterHeader};
724719
use bitcoin::block::{Block, BlockHash};
725720
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
726721
use bitcoin::script::ScriptBuf;
727722
use bitcoin::transaction::{Transaction, Txid};
723+
use hex_lit::hex;
724+
use units::BlockHeight;
725+
726+
use super::*;
728727
use crate::address::AddrV2;
729728
use crate::message_blockdata::{GetBlocksMessage, GetHeadersMessage, Inventory};
730729
use crate::message_bloom::{BloomFlags, FilterAdd, FilterLoad};

p2p/src/message_blockdata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
//! This module describes network messages which are used for passing
66
//! Bitcoin data (blocks and transactions) around.
77
8-
use io::{BufRead, Write};
9-
108
use bitcoin::block::BlockHash;
119
use bitcoin::consensus::encode::{self, Decodable, Encodable};
1210
use bitcoin::transaction::{Txid, Wtxid};
11+
use io::{BufRead, Write};
12+
1313
use crate::consensus::impl_consensus_encoding;
1414

1515
/// An inventory item.
@@ -143,10 +143,10 @@ impl_consensus_encoding!(GetHeadersMessage, version, locator_hashes, stop_hash);
143143

144144
#[cfg(test)]
145145
mod tests {
146+
use bitcoin::consensus::encode::{deserialize, serialize};
146147
use hex_lit::hex;
147148

148149
use super::*;
149-
use bitcoin::consensus::encode::{deserialize, serialize};
150150

151151
#[test]
152152
fn getblocks_message() {

p2p/src/message_bloom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//!
55
//! This module describes BIP37 Connection Bloom filtering network messages.
66
7+
use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt};
78
use io::{BufRead, Write};
89

9-
use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt};
1010
use crate::consensus::impl_consensus_encoding;
1111

1212
/// `filterload` message sets the current bloom filter

p2p/src/message_compact_blocks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! BIP152 Compact Blocks network messages
55
66
use bitcoin::bip152;
7+
78
use crate::consensus::impl_consensus_encoding;
89

910
/// sendcmpct message

p2p/src/message_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//!
55
//! This module describes BIP157 Client Side Block Filtering network messages.
66
7-
use units::BlockHeight;
8-
97
use bitcoin::bip158::{FilterHash, FilterHeader};
108
use bitcoin::block::BlockHash;
9+
use units::BlockHeight;
10+
1111
use crate::consensus::impl_consensus_encoding;
1212

1313
/// getcfilters message

0 commit comments

Comments
 (0)