Fix clippy lints.

This commit is contained in:
Henry de Valence 2020-02-13 10:11:39 -08:00 committed by Deirdre Connolly
parent 8000f888fd
commit b443d7a4be
2 changed files with 8 additions and 5 deletions

View File

@ -70,7 +70,7 @@ fn parse_coinbase_height(mut data: Vec<u8>) -> Result<(BlockHeight, Vec<u8>), Se
// while remaining below the maximum `BlockHeight` of 500_000_000 forced by `LockTime`. // while remaining below the maximum `BlockHeight` of 500_000_000 forced by `LockTime`.
// While it's unlikely this code will ever process a block height that high, this means // While it's unlikely this code will ever process a block height that high, this means
// we don't need to maintain a cascade of different invariants for allowable `BlockHeight`s. // we don't need to maintain a cascade of different invariants for allowable `BlockHeight`s.
(Some(0x04), _) if &data[..] == &GENESIS_COINBASE_DATA[..] => Ok((BlockHeight(0), data)), (Some(0x04), _) if data[..] == GENESIS_COINBASE_DATA[..] => Ok((BlockHeight(0), data)),
// As noted above, this is included for completeness. // As noted above, this is included for completeness.
(Some(0x04), len) if len >= 5 => { (Some(0x04), len) if len >= 5 => {
let h = data[1] as u32 let h = data[1] as u32
@ -100,9 +100,9 @@ fn coinbase_height_len(height: BlockHeight) -> usize {
2 2
} else if let _h @ 256..=65535 = height.0 { } else if let _h @ 256..=65535 = height.0 {
3 3
} else if let _h @ 65536..=16777215 = height.0 { } else if let _h @ 65536..=16_777_215 = height.0 {
4 4
} else if let _h @ 16777216..=499_999_999 = height.0 { } else if let _h @ 16_777_216..=499_999_999 = height.0 {
5 5
} else { } else {
panic!("Invalid coinbase height"); panic!("Invalid coinbase height");
@ -122,12 +122,12 @@ fn write_coinbase_height<W: io::Write>(height: BlockHeight, mut w: W) -> Result<
} else if let h @ 256..=65535 = height.0 { } else if let h @ 256..=65535 = height.0 {
w.write_u8(0x02)?; w.write_u8(0x02)?;
w.write_u16::<LittleEndian>(h as u16)?; w.write_u16::<LittleEndian>(h as u16)?;
} else if let h @ 65536..=16777215 = height.0 { } else if let h @ 65536..=16_777_215 = height.0 {
w.write_u8(0x03)?; w.write_u8(0x03)?;
w.write_u8(h as u8)?; w.write_u8(h as u8)?;
w.write_u8((h >> 8) as u8)?; w.write_u8((h >> 8) as u8)?;
w.write_u8((h >> 16) as u8)?; w.write_u8((h >> 16) as u8)?;
} else if let h @ 16777216..=499_999_999 = height.0 { } else if let h @ 16_777_216..=499_999_999 = height.0 {
w.write_u8(0x04)?; w.write_u8(0x04)?;
w.write_u32::<LittleEndian>(h)?; w.write_u32::<LittleEndian>(h)?;
} else { } else {

View File

@ -14,6 +14,9 @@
//#![deny(warnings, missing_docs, trivial_casts, unused_qualifications)] //#![deny(warnings, missing_docs, trivial_casts, unused_qualifications)]
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
// Tracing causes false positives on this lint:
// https://github.com/tokio-rs/tracing/issues/553
#![allow(clippy::cognitive_complexity)]
#[macro_use] #[macro_use]
extern crate tracing; extern crate tracing;