What changed, and why it matters
This commit is an automated code-formatting run by rustfmt. It only changes whitespace, line breaks, and the order of import statements. There are no functional changes, no bug fixes, and no security-related alterations.
No action required; this is a routine formatting commit with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows purely cosmetic changes produced by rustfmt nightly: rewrapping function bodies and closures, reordering use statements alphabetically, and reformatting assert! macro calls. No logic, constants, types, visibility, or control flow were modified. The only non-whitespace changes are import reorderings, which are semantically equivalent in Rust.
Changed components
consensus_encoding/src/decode/decoders.rsconsensus_encoding/src/lib.rsinternals/src/serde.rsp2p/src/message.rsp2p/src/message_blockdata.rsp2p/src/message_filter.rsp2p/src/message_network.rsunits/src/time.rsInspect captured patch +41 / −36
diff --git a/consensus_encoding/src/decode/decoders.rs b/consensus_encoding/src/decode/decoders.rs
index 0a7e3b71..1ddafa40 100644
--- a/consensus_encoding/src/decode/decoders.rs
+++ b/consensus_encoding/src/decode/decoders.rs
@@ -615,13 +615,17 @@ impl CompactSizeDecoder {
///
/// The final call to [`CompactSizeDecoder::end`] on this decoder will fail if the
/// decoded value exceeds 4,000,000 or won't fit in a `usize`.
- pub const fn new() -> Self { Self { buf: internals::array_vec::ArrayVec::new(), limit: MAX_VEC_SIZE } }
+ pub const fn new() -> Self {
+ Self { buf: internals::array_vec::ArrayVec::new(), limit: MAX_VEC_SIZE }
+ }
/// Constructs a new compact size decoder with encoded value limited to the provided usize.
///
/// The final call to [`CompactSizeDecoder::end`] on this decoder will fail if the
/// decoded value exceeds `limit` or won't fit in a `usize`.
- pub const fn new_with_limit(limit: usize) -> Self { Self { buf: internals::array_vec::ArrayVec::new(), limit } }
+ pub const fn new_with_limit(limit: usize) -> Self {
+ Self { buf: internals::array_vec::ArrayVec::new(), limit }
+ }
}
impl Default for CompactSizeDecoder {
@@ -698,24 +702,20 @@ impl Decoder for CompactSizeDecoder {
// This error is returned if dec_value is outside of the usize range, or
// if it is above the given limit.
- let make_err = || {
- CompactSizeDecoderError(
- E::ValueExceedsLimit(LengthPrefixExceedsMaxError {
- value: dec_value,
- limit: self.limit,
- })
- )
+ let make_err = || {
+ CompactSizeDecoderError(E::ValueExceedsLimit(LengthPrefixExceedsMaxError {
+ value: dec_value,
+ limit: self.limit,
+ }))
};
- usize::try_from(dec_value)
- .map_err(|_| make_err())
- .and_then(|nsize| {
- if nsize > self.limit {
- Err(make_err())
- } else {
- Ok(nsize)
- }
- })
+ usize::try_from(dec_value).map_err(|_| make_err()).and_then(|nsize| {
+ if nsize > self.limit {
+ Err(make_err())
+ } else {
+ Ok(nsize)
+ }
+ })
}
fn read_limit(&self) -> usize {
diff --git a/consensus_encoding/src/lib.rs b/consensus_encoding/src/lib.rs
index ae9d4847..2f5a315b 100644
--- a/consensus_encoding/src/lib.rs
+++ b/consensus_encoding/src/lib.rs
@@ -20,15 +20,14 @@ extern crate std;
mod decode;
mod encode;
-#[cfg(feature = "alloc")]
-pub use self::decode::decoders::{
- ByteVecDecoder, ByteVecDecoderError, LengthPrefixExceedsMaxError,
- VecDecoder, VecDecoderError,
-};
pub use self::decode::decoders::{
ArrayDecoder, CompactSizeDecoder, CompactSizeDecoderError, Decoder2, Decoder2Error, Decoder3,
Decoder3Error, Decoder4, Decoder4Error, Decoder6, Decoder6Error, UnexpectedEofError,
};
+#[cfg(feature = "alloc")]
+pub use self::decode::decoders::{
+ ByteVecDecoder, ByteVecDecoderError, LengthPrefixExceedsMaxError, VecDecoder, VecDecoderError,
+};
#[cfg(feature = "std")]
pub use self::decode::{
decode_from_read, decode_from_read_unbuffered, decode_from_read_unbuffered_with, ReadError,
diff --git a/internals/src/serde.rs b/internals/src/serde.rs
index eb4abde5..bb52e9ef 100644
--- a/internals/src/serde.rs
+++ b/internals/src/serde.rs
@@ -31,7 +31,7 @@ pub trait IntoDeError: Sized {
}
mod impls {
- use super::{IntoDeError, de};
+ use super::{de, IntoDeError};
impl IntoDeError for core::convert::Infallible {
fn into_de_error<E: de::Error>(self, _expected: Option<&dyn de::Expected>) -> E {
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index ec75a77f..555c5a38 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -16,11 +16,11 @@ use core::{cmp, fmt};
use arbitrary::{Arbitrary, Unstructured};
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use bitcoin::merkle_tree::MerkleBlock;
-use primitives::{block, transaction};
use encoding;
use hashes::sha256d;
use internals::ToU64 as _;
use io::{self, BufRead, Read, Write};
+use primitives::{block, transaction};
use units::FeeRate;
use crate::address::{AddrV2Message, Address};
@@ -1660,10 +1660,10 @@ mod test {
use alloc::vec;
use std::net::Ipv4Addr;
- use primitives::{Block, BlockHash};
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
- use primitives::transaction::{Transaction, Txid};
use hex_lit::hex;
+ use primitives::transaction::{Transaction, Txid};
+ use primitives::{Block, BlockHash};
use units::BlockHeight;
use super::*;
diff --git a/p2p/src/message_blockdata.rs b/p2p/src/message_blockdata.rs
index a6b25c2c..3db68a27 100644
--- a/p2p/src/message_blockdata.rs
+++ b/p2p/src/message_blockdata.rs
@@ -9,10 +9,10 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use primitives::BlockHash;
use bitcoin::consensus::encode::{self, Decodable, Encodable};
-use primitives::transaction::{Txid, Wtxid};
use io::{BufRead, Write};
+use primitives::transaction::{Txid, Wtxid};
+use primitives::BlockHash;
use crate::consensus::impl_consensus_encoding;
use crate::ProtocolVersion;
diff --git a/p2p/src/message_filter.rs b/p2p/src/message_filter.rs
index 9f740dce..bed5ea33 100644
--- a/p2p/src/message_filter.rs
+++ b/p2p/src/message_filter.rs
@@ -8,8 +8,8 @@ use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use primitives::BlockHash;
use hashes::{sha256d, HashEngine};
+use primitives::BlockHash;
use units::BlockHeight;
use crate::consensus::impl_consensus_encoding;
diff --git a/p2p/src/message_network.rs b/p2p/src/message_network.rs
index 5f364a32..7ff700f1 100644
--- a/p2p/src/message_network.rs
+++ b/p2p/src/message_network.rs
@@ -109,11 +109,17 @@ impl UserAgent {
const MAX_USER_AGENT_LEN: usize = 256;
fn panic_invalid_chars(agent_str: &str) {
- assert!(!agent_str.chars().any(|c| matches!(c, '/' | '(' | ')' | ':')), "user agent configuration cannot contain: / ( ) :");
+ assert!(
+ !agent_str.chars().any(|c| matches!(c, '/' | '(' | ')' | ':')),
+ "user agent configuration cannot contain: / ( ) :"
+ );
}
fn panic_max_len(agent_str: &str) {
- assert!(agent_str.chars().count() <= Self::MAX_USER_AGENT_LEN, "user agent cannot exceed 256 characters.");
+ assert!(
+ agent_str.chars().count() <= Self::MAX_USER_AGENT_LEN,
+ "user agent cannot exceed 256 characters."
+ );
}
/// Builds a new user agent from the lowest level client software. For example: `Satoshi` is
/// used by Bitcoin Core.
diff --git a/units/src/time.rs b/units/src/time.rs
index c93609a6..a16b3906 100644
--- a/units/src/time.rs
+++ b/units/src/time.rs
@@ -168,12 +168,12 @@ impl<'a> Arbitrary<'a> for BlockTime {
#[cfg(test)]
mod tests {
- use super::*;
-
- #[cfg(feature = "encoding")]
- use encoding::{Decodable as _, Decoder as _};
#[cfg(all(feature = "encoding", feature = "alloc"))]
use encoding::UnexpectedEofError;
+ #[cfg(feature = "encoding")]
+ use encoding::{Decodable as _, Decoder as _};
+
+ use super::*;
#[test]
fn block_time_round_trip() {
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.