Skip to content

Commit 3ab34e4

Browse files
committed
clippy: fix unreadable_literal lint
I think this is a style improvement.
1 parent a314993 commit 3ab34e4

File tree

9 files changed

+42
-42
lines changed

9 files changed

+42
-42
lines changed

src/blech32/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ impl bech32::Checksum for Blech32 {
3030
type MidstateRepr = u64;
3131
const CHECKSUM_LENGTH: usize = 12;
3232
const GENERATOR_SH: [u64; 5] = [
33-
0x7d52fba40bd886,
34-
0x5e8dbf1a03950c,
35-
0x1c3a3c74072a18,
36-
0x385d72fa0e5139,
37-
0x7093e5a608865b,
33+
0x7d_52fb_a40b_d886,
34+
0x5e_8dbf_1a03_950c,
35+
0x1c_3a3c_7407_2a18,
36+
0x38_5d72_fa0e_5139,
37+
0x70_93e5_a608_865b,
3838
];
3939
const TARGET_RESIDUE: u64 = 1;
4040

@@ -49,13 +49,13 @@ impl bech32::Checksum for Blech32m {
4949
type MidstateRepr = u64;
5050
const CHECKSUM_LENGTH: usize = 12;
5151
const GENERATOR_SH: [u64; 5] = [
52-
0x7d52fba40bd886,
53-
0x5e8dbf1a03950c,
54-
0x1c3a3c74072a18,
55-
0x385d72fa0e5139,
56-
0x7093e5a608865b,
52+
0x7d_52fb_a40b_d886,
53+
0x5e_8dbf_1a03_950c,
54+
0x1c_3a3c_7407_2a18,
55+
0x38_5d72_fa0e_5139,
56+
0x70_93e5_a608_865b,
5757
];
58-
const TARGET_RESIDUE: u64 = 0x455972a3350f7a1;
58+
const TARGET_RESIDUE: u64 = 0x455_972a_3350_f7a1;
5959

6060
const CODE_LENGTH: usize = 1024;
6161
}

src/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ mod tests {
463463
block.block_hash().to_string(),
464464
"287ca47e8da47eb8c28d870663450bb026922eadb30a1b2f8293e6e9d1ca5322"
465465
);
466-
assert_eq!(block.header.version, 0x20000000);
466+
assert_eq!(block.header.version, 0x2000_0000);
467467
assert_eq!(block.header.height, 2);
468468
assert_eq!(block.txdata.len(), 1);
469469
assert_eq!(block.size(), serialize(&block).len());
@@ -675,7 +675,7 @@ mod tests {
675675
block.block_hash().to_string(),
676676
"e935d06cf3a616eb4d551338598b84daa0e8592ed14673263597f6af4b4a6ea6"
677677
);
678-
assert_eq!(block.header.version, 0x20000000);
678+
assert_eq!(block.header.version, 0x2000_0000);
679679
assert_eq!(block.header.height, 1);
680680
assert_eq!(block.txdata.len(), 3);
681681
assert_eq!(block.size(), serialize(&block).len());
@@ -706,7 +706,7 @@ mod tests {
706706
block.block_hash().to_string(),
707707
"bcc6eb2ab6c97b9b4590825b9136f100b22e090c0469818572b8b93926a79f28"
708708
);
709-
assert_eq!(block.header.version, 0x20000000);
709+
assert_eq!(block.header.version, 0x2000_0000);
710710
if let ExtData::Proof { challenge, solution } = block.header.ext {
711711
assert_eq!(challenge.len(), 1 + 3 * 34 + 2);
712712
assert_eq!(solution.len(), 144);
@@ -740,7 +740,7 @@ mod tests {
740740
block.block_hash().to_string(),
741741
"4961df970cf12d789383974e6ab439f780d956b5a50162ca9d281362e46c605a"
742742
);
743-
assert_eq!(block.header.version, 0x20000000);
743+
assert_eq!(block.header.version, 0x2000_0000);
744744

745745
// Full current and proposal
746746
let block: Block = hex_deserialize!("\

src/confidential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ mod tests {
11681168
&[
11691169
Token::Seq { len: Some(2) },
11701170
Token::U8(1),
1171-
Token::U64(63601271583539200),
1171+
Token::U64(63_601_271_583_539_200),
11721172
Token::SeqEnd
11731173
]
11741174
);

src/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl VarInt {
260260
match self.0 {
261261
0..=0xFC => 1,
262262
0xFD..=0xFFFF => 3,
263-
0x10000..=0xFFFFFFFF => 5,
263+
0x10000..=0xFFFF_FFFF => 5,
264264
_ => 9,
265265
}
266266
}

src/endian.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ mod tests {
2020

2121
#[test]
2222
fn endianness_test() {
23-
assert_eq!(u32_to_array_le(0xdeadbeef), [0xef, 0xbe, 0xad, 0xde]);
23+
assert_eq!(u32_to_array_le(0xdead_beef), [0xef, 0xbe, 0xad, 0xde]);
2424
}
2525
}

src/ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl<W: io::Write + ?Sized> WriteExt for W {
119119
self.emit_u16(i as u16)?;
120120
Ok(3)
121121
}
122-
i @ 0x10000..=0xFFFFFFFF => {
122+
i @ 0x10000..=0xFFFF_FFFF => {
123123
self.emit_u8(0xFE)?;
124124
self.emit_u32(i as u32)?;
125125
Ok(5)
@@ -166,7 +166,7 @@ impl<R: io::Read + ?Sized> ReadExt for R {
166166
match self.read_u8()? {
167167
0xFF => {
168168
let x = self.read_u64()?;
169-
if x < 0x100000000 {
169+
if x < 0x1_0000_0000 {
170170
Err(encode::Error::NonMinimalVarInt)
171171
} else {
172172
Ok(x)

src/script.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -786,17 +786,17 @@ impl Builder {
786786
self.0.push(opcodes::Ordinary::OP_PUSHDATA1.into_u8());
787787
self.0.push(n as u8);
788788
},
789-
n if n < 0x10000 => {
789+
n if n < 0x1_0000 => {
790790
self.0.push(opcodes::Ordinary::OP_PUSHDATA2.into_u8());
791791
self.0.push((n % 0x100) as u8);
792792
self.0.push((n / 0x100) as u8);
793793
},
794-
n if n < 0x100000000 => {
794+
n if n < 0x1_0000_0000 => {
795795
self.0.push(opcodes::Ordinary::OP_PUSHDATA4.into_u8());
796796
self.0.push((n % 0x100) as u8);
797797
self.0.push(((n / 0x100) % 0x100) as u8);
798-
self.0.push(((n / 0x10000) % 0x100) as u8);
799-
self.0.push((n / 0x1000000) as u8);
798+
self.0.push(((n / 0x1_0000) % 0x100) as u8);
799+
self.0.push((n / 0x100_0000) as u8);
800800
}
801801
_ => panic!("tried to put a 4bn+ sized object into a script!")
802802
}
@@ -977,10 +977,10 @@ mod test {
977977
script = script.push_scriptint(4); comp.extend([1u8, 4].iter().copied()); assert_eq!(&script[..], &comp[..]);
978978
// big ints
979979
script = script.push_int(17); comp.extend([1u8, 17].iter().copied()); assert_eq!(&script[..], &comp[..]);
980-
script = script.push_int(10000); comp.extend([2u8, 16, 39].iter().copied()); assert_eq!(&script[..], &comp[..]);
980+
script = script.push_int(10_000); comp.extend([2u8, 16, 39].iter().copied()); assert_eq!(&script[..], &comp[..]);
981981
// notice the sign bit set here, hence the extra zero/128 at the end
982-
script = script.push_int(10000000); comp.extend([4u8, 128, 150, 152, 0].iter().copied()); assert_eq!(&script[..], &comp[..]);
983-
script = script.push_int(-10000000); comp.extend([4u8, 128, 150, 152, 128].iter().copied()); assert_eq!(&script[..], &comp[..]);
982+
script = script.push_int(10_000_000); comp.extend([4u8, 128, 150, 152, 0].iter().copied()); assert_eq!(&script[..], &comp[..]);
983+
script = script.push_int(-10_000_000); comp.extend([4u8, 128, 150, 152, 128].iter().copied()); assert_eq!(&script[..], &comp[..]);
984984

985985
// data
986986
script = script.push_slice(b"NRA4VR"); comp.extend([6u8, 78, 82, 65, 52, 86, 82].iter().copied()); assert_eq!(&script[..], &comp[..]);
@@ -1097,7 +1097,7 @@ mod test {
10971097
assert_eq!(build_scriptint(256), vec![0, 1]);
10981098
assert_eq!(build_scriptint(257), vec![1, 1]);
10991099
assert_eq!(build_scriptint(511), vec![255, 1]);
1100-
for &i in &[10, 100, 255, 256, 1000, 10000, 25000, 200000, 5000000, 1000000000,
1100+
for &i in &[10, 100, 255, 256, 1000, 10000, 25000, 200_000, 5_000_000, 1_000_000_000,
11011101
(1 << 31) - 1, -((1 << 31) - 1)] {
11021102
assert_eq!(Ok(i), read_scriptint(&build_scriptint(i)));
11031103
assert_eq!(Ok(-i), read_scriptint(&build_scriptint(-i)));

src/sighash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'s> ScriptPath<'s> {
212212
}
213213
/// Create a new `ScriptPath` structure using default values for `code_separator_pos` and `leaf_version`
214214
pub fn with_defaults(script: &'s Script) -> Self {
215-
Self::new(script, 0xFFFFFFFFu32, 0xc4)
215+
Self::new(script, 0xFFFF_FFFFu32, 0xc4)
216216
}
217217

218218
/// Compute the leaf hash
@@ -483,7 +483,7 @@ impl<R: Deref<Target = Transaction>> SighashCache<R> {
483483
input_index,
484484
prevouts,
485485
None,
486-
Some((leaf_hash.into(), 0xFFFFFFFF)),
486+
Some((leaf_hash.into(), 0xFFFF_FFFF)),
487487
sighash_type,
488488
genesis_hash
489489
)?;

src/transaction.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl Sequence {
187187
/// The maximum allowable sequence number.
188188
///
189189
/// This sequence number disables lock-time and replace-by-fee.
190-
pub const MAX: Self = Sequence(0xFFFFFFFF);
190+
pub const MAX: Self = Sequence(0xFFFF_FFFF);
191191
/// Zero value sequence.
192192
///
193193
/// This sequence number enables replace-by-fee and lock-time.
@@ -197,7 +197,7 @@ impl Sequence {
197197
pub const ENABLE_LOCKTIME_NO_RBF: Self = Sequence::MIN_NO_RBF;
198198
/// The sequence number that enables replace-by-fee and absolute lock-time but
199199
/// disables relative lock-time.
200-
pub const ENABLE_RBF_NO_LOCKTIME: Self = Sequence(0xFFFFFFFD);
200+
pub const ENABLE_RBF_NO_LOCKTIME: Self = Sequence(0xFFFF_FFFD);
201201

202202
/// The lowest sequence number that does not opt-in for replace-by-fee.
203203
///
@@ -206,11 +206,11 @@ impl Sequence {
206206
/// (Explicit Signalling [BIP-125]).
207207
///
208208
/// [BIP-125]: <https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki]>
209-
const MIN_NO_RBF: Self = Sequence(0xFFFFFFFE);
209+
const MIN_NO_RBF: Self = Sequence(0xFFFF_FFFE);
210210
/// BIP-68 relative lock-time disable flag mask
211-
const LOCK_TIME_DISABLE_FLAG_MASK: u32 = 0x80000000;
211+
const LOCK_TIME_DISABLE_FLAG_MASK: u32 = 0x8000_0000;
212212
/// BIP-68 relative lock-time type flag mask
213-
const LOCK_TYPE_MASK: u32 = 0x00400000;
213+
const LOCK_TYPE_MASK: u32 = 0x0040_0000;
214214

215215
/// Returns `true` if the sequence number indicates that the transaction is finalised.
216216
///
@@ -545,7 +545,7 @@ impl Decodable for TxIn {
545545
let has_issuance;
546546
// Pegin/issuance flags are encoded into the high bits of `vout`, *except*
547547
// if vout is all 1's; this indicates a coinbase transaction
548-
if outp.vout == 0xffffffff {
548+
if outp.vout == 0xffff_ffff {
549549
is_pegin = false;
550550
has_issuance = false;
551551
} else {
@@ -1373,10 +1373,10 @@ mod tests {
13731373
assert_eq!(tx.weight(), tx.size() * 4);
13741374
assert!(!tx.output[0].is_fee());
13751375
assert!(tx.output[1].is_fee());
1376-
assert_eq!(tx.output[0].value, confidential::Value::Explicit(9999996700));
1377-
assert_eq!(tx.output[1].value, confidential::Value::Explicit( 3300));
1378-
assert_eq!(tx.output[0].minimum_value(), 9999996700);
1379-
assert_eq!(tx.output[1].minimum_value(), 3300);
1376+
assert_eq!(tx.output[0].value, confidential::Value::Explicit(9_999_996_700));
1377+
assert_eq!(tx.output[1].value, confidential::Value::Explicit(3300));
1378+
assert_eq!(tx.output[0].minimum_value(), 9_999_996_700);
1379+
assert_eq!(tx.output[1].minimum_value(), 3300);
13801380
let fee_asset = "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23".parse().unwrap();
13811381
assert_eq!(tx.fee_in(fee_asset), 3300);
13821382
assert_eq!(tx.all_fees()[&fee_asset], 3300);
@@ -1688,7 +1688,7 @@ mod tests {
16881688
).unwrap(),
16891689
vout: 0,
16901690
},
1691-
value: 100000000,
1691+
value: 100_000_000,
16921692
asset: tx.output[0].asset.explicit().unwrap(),
16931693
genesis_hash: bitcoin::BlockHash::from_str(
16941694
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
@@ -1803,7 +1803,7 @@ mod tests {
18031803
tx.output[0].pegout_data(),
18041804
Some(super::PegoutData {
18051805
asset: tx.output[0].asset,
1806-
value: 99993900,
1806+
value: 99_993_900,
18071807
genesis_hash: bitcoin::BlockHash::from_str(
18081808
"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
18091809
).unwrap(),

0 commit comments

Comments
 (0)