1616#![ allow( clippy:: uninlined_format_args) ] // Allow `format!("{}", x)`instead of enforcing `format!("{x}")`
1717
1818pub mod address;
19+ mod consensus;
1920pub mod message;
2021pub mod message_blockdata;
2122pub mod message_bloom;
2223pub mod message_compact_blocks;
2324pub mod message_filter;
2425pub mod message_network;
25- mod consensus;
2626
2727extern crate alloc;
2828
2929use core:: str:: FromStr ;
3030use core:: { fmt, ops} ;
31-
3231use std:: borrow:: { Borrow , BorrowMut , ToOwned } ;
3332
33+ use bitcoin:: consensus:: encode:: { self , Decodable , Encodable } ;
34+ use bitcoin:: network:: { Network , Params , TestnetVersion } ;
3435use hex:: FromHex ;
3536use internals:: impl_to_hex_from_lower_hex;
3637use 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) ]
4341pub 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
249249impl FromStr for Magic {
@@ -409,9 +409,10 @@ impl std::error::Error for UnknownNetworkError {
409409
410410#[ cfg( test) ]
411411mod 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 = [
0 commit comments