Fix new clippy lints in clippy nightly (#3176)
This commit is contained in:
parent
0ad89f2f41
commit
4ce6fbccc4
|
@ -132,24 +132,21 @@ impl Block {
|
|||
pub fn sprout_nullifiers(&self) -> impl Iterator<Item = &sprout::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.sprout_nullifiers())
|
||||
.flatten()
|
||||
.flat_map(|transaction| transaction.sprout_nullifiers())
|
||||
}
|
||||
|
||||
/// Access the [`sapling::Nullifier`]s from all transactions in this block.
|
||||
pub fn sapling_nullifiers(&self) -> impl Iterator<Item = &sapling::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.sapling_nullifiers())
|
||||
.flatten()
|
||||
.flat_map(|transaction| transaction.sapling_nullifiers())
|
||||
}
|
||||
|
||||
/// Access the [`orchard::Nullifier`]s from all transactions in this block.
|
||||
pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
|
||||
self.transactions
|
||||
.iter()
|
||||
.map(|transaction| transaction.orchard_nullifiers())
|
||||
.flatten()
|
||||
.flat_map(|transaction| transaction.orchard_nullifiers())
|
||||
}
|
||||
|
||||
/// Count how many Sapling transactions exist in a block,
|
||||
|
|
|
@ -184,7 +184,7 @@ where
|
|||
.map(|tx| {
|
||||
tx.as_ref()
|
||||
.auth_digest()
|
||||
.unwrap_or_else(|| transaction::AuthDigest([0xFF; 32]))
|
||||
.unwrap_or(transaction::AuthDigest([0xFF; 32]))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
|
@ -92,14 +92,13 @@ impl NonAdjacentForm for pallas::Scalar {
|
|||
// Construct a buffer of bits of the scalar, starting at bit `pos`
|
||||
let u64_idx = pos / 64;
|
||||
let bit_idx = pos % 64;
|
||||
let bit_buf: u64;
|
||||
if bit_idx < 64 - w {
|
||||
let bit_buf: u64 = if bit_idx < 64 - w {
|
||||
// This window's bits are contained in a single u64
|
||||
bit_buf = x_u64[u64_idx] >> bit_idx;
|
||||
x_u64[u64_idx] >> bit_idx
|
||||
} else {
|
||||
// Combine the current u64's bits with the bits from the next u64
|
||||
bit_buf = (x_u64[u64_idx] >> bit_idx) | (x_u64[1 + u64_idx] << (64 - bit_idx));
|
||||
}
|
||||
(x_u64[u64_idx] >> bit_idx) | (x_u64[1 + u64_idx] << (64 - bit_idx))
|
||||
};
|
||||
|
||||
// Add the carry into the current window
|
||||
let window = carry + (bit_buf & window_mask);
|
||||
|
|
|
@ -116,12 +116,12 @@ impl NoteCommitment {
|
|||
//
|
||||
// The `TryFrom<Diversifier>` impls for the `jubjub::*Point`s handles
|
||||
// calling `DiversifyHash` implicitly.
|
||||
let g_d_bytes: [u8; 32];
|
||||
if let Ok(g_d) = jubjub::AffinePoint::try_from(diversifier) {
|
||||
g_d_bytes = g_d.to_bytes();
|
||||
|
||||
let g_d_bytes: [u8; 32] = if let Ok(g_d) = jubjub::AffinePoint::try_from(diversifier) {
|
||||
g_d.to_bytes()
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let pk_d_bytes = <[u8; 32]>::from(transmission_key);
|
||||
let v_bytes = value.to_bytes();
|
||||
|
|
|
@ -871,8 +871,7 @@ impl Transaction {
|
|||
pub fn orchard_actions(&self) -> impl Iterator<Item = &orchard::Action> {
|
||||
self.orchard_shielded_data()
|
||||
.into_iter()
|
||||
.map(orchard::ShieldedData::actions)
|
||||
.flatten()
|
||||
.flat_map(orchard::ShieldedData::actions)
|
||||
}
|
||||
|
||||
/// Access the [`orchard::Nullifier`]s in this transaction, if there are any,
|
||||
|
@ -880,8 +879,7 @@ impl Transaction {
|
|||
pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
|
||||
self.orchard_shielded_data()
|
||||
.into_iter()
|
||||
.map(orchard::ShieldedData::nullifiers)
|
||||
.flatten()
|
||||
.flat_map(orchard::ShieldedData::nullifiers)
|
||||
}
|
||||
|
||||
/// Access the note commitments in this transaction, if there are any,
|
||||
|
@ -889,8 +887,7 @@ impl Transaction {
|
|||
pub fn orchard_note_commitments(&self) -> impl Iterator<Item = &pallas::Base> {
|
||||
self.orchard_shielded_data()
|
||||
.into_iter()
|
||||
.map(orchard::ShieldedData::note_commitments)
|
||||
.flatten()
|
||||
.flat_map(orchard::ShieldedData::note_commitments)
|
||||
}
|
||||
|
||||
/// Access the [`orchard::Flags`] in this transaction, if there is any,
|
||||
|
|
|
@ -847,8 +847,7 @@ pub fn transaction_to_fake_v5(
|
|||
expiry_height: height,
|
||||
sapling_shielded_data: sapling_shielded_data
|
||||
.clone()
|
||||
.map(sapling_shielded_v4_to_fake_v5)
|
||||
.flatten(),
|
||||
.and_then(sapling_shielded_v4_to_fake_v5),
|
||||
orchard_shielded_data: None,
|
||||
},
|
||||
v5 @ V5 { .. } => v5.clone(),
|
||||
|
|
|
@ -34,15 +34,13 @@ impl<'a> TryFrom<&'a [u8]> for Memo {
|
|||
|
||||
impl fmt::Debug for Memo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let output: String;
|
||||
|
||||
// This saves work but if the 'valid utf8 string' is just a
|
||||
// bunch of numbers, it prints them out like
|
||||
// 'Memo("\u{0}\u{0}..")', so. ¯\_(ツ)_/¯
|
||||
match std::str::from_utf8(&self.0[..]) {
|
||||
Ok(memo) => output = String::from(memo),
|
||||
_ => output = hex::encode(&self.0[..]),
|
||||
}
|
||||
let output: String = match std::str::from_utf8(&self.0[..]) {
|
||||
Ok(memo) => String::from(memo),
|
||||
_ => hex::encode(&self.0[..]),
|
||||
};
|
||||
|
||||
f.debug_tuple("Memo").field(&output).finish()
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ fn parse_coinbase_height_mins() {
|
|||
// examples with height 1:
|
||||
|
||||
let case1 = vec![0x51];
|
||||
assert!(!parse_coinbase_height(case1.clone()).is_err());
|
||||
assert!(parse_coinbase_height(case1.clone()).is_ok());
|
||||
assert_eq!(parse_coinbase_height(case1).unwrap().0 .0, 1);
|
||||
|
||||
let case2 = vec![0x01, 0x01];
|
||||
|
@ -25,7 +25,7 @@ fn parse_coinbase_height_mins() {
|
|||
// examples with height 17:
|
||||
|
||||
let case1 = vec![0x01, 0x11];
|
||||
assert!(!parse_coinbase_height(case1.clone()).is_err());
|
||||
assert!(parse_coinbase_height(case1.clone()).is_ok());
|
||||
assert_eq!(parse_coinbase_height(case1).unwrap().0 .0, 17);
|
||||
|
||||
let case2 = vec![0x02, 0x11, 0x00];
|
||||
|
|
|
@ -344,9 +344,7 @@ proptest! {
|
|||
|
||||
// If `change` is invalid for the current MetaAddr state, skip it.
|
||||
// If we've run out of changes for this addr, do nothing.
|
||||
if let Some(changed_addr) = change
|
||||
.map(|change| change.apply_to_meta_addr(*addr))
|
||||
.flatten()
|
||||
if let Some(changed_addr) = change.and_then(|change| change.apply_to_meta_addr(*addr))
|
||||
{
|
||||
prop_assert_eq!(changed_addr.addr, addr.addr);
|
||||
*addr = changed_addr;
|
||||
|
|
|
@ -157,9 +157,8 @@ impl Config {
|
|||
}
|
||||
|
||||
// Try the hard limit or the minimum, whichever is greater
|
||||
let min_limit = if let Some(hard_limit) =
|
||||
hard_rlimit.map(TryInto::try_into).map(Result::ok).flatten()
|
||||
{
|
||||
let min_limit =
|
||||
if let Some(hard_limit) = hard_rlimit.map(TryInto::try_into).and_then(Result::ok) {
|
||||
std::cmp::max(Config::MIN_OPEN_FILE_LIMIT, hard_limit)
|
||||
} else {
|
||||
Config::MIN_OPEN_FILE_LIMIT
|
||||
|
|
|
@ -473,7 +473,7 @@ impl StateService {
|
|||
(max_height - 1).expect("max_len is at least 1")
|
||||
};
|
||||
|
||||
let stop_height = stop.map(|hash| self.best_height_by_hash(hash)).flatten();
|
||||
let stop_height = stop.and_then(|hash| self.best_height_by_hash(hash));
|
||||
|
||||
// Compute the final height, making sure it is:
|
||||
// * at or below our chain tip, and
|
||||
|
|
|
@ -542,8 +542,7 @@ impl FinalizedState {
|
|||
let (finalized, rsp_tx) = queued_block;
|
||||
let result = self.commit_finalized_direct(finalized.clone(), "CommitFinalized request");
|
||||
|
||||
let block_result;
|
||||
if result.is_ok() {
|
||||
let block_result = if result.is_ok() {
|
||||
metrics::counter!("state.checkpoint.finalized.block.count", 1);
|
||||
metrics::gauge!(
|
||||
"state.checkpoint.finalized.block.height",
|
||||
|
@ -556,7 +555,7 @@ impl FinalizedState {
|
|||
metrics::gauge!("zcash.chain.verified.block.height", finalized.height.0 as _);
|
||||
metrics::counter!("zcash.chain.verified.block.total", 1);
|
||||
|
||||
block_result = Ok(finalized);
|
||||
Ok(finalized)
|
||||
} else {
|
||||
metrics::counter!("state.checkpoint.error.block.count", 1);
|
||||
metrics::gauge!(
|
||||
|
@ -564,8 +563,8 @@ impl FinalizedState {
|
|||
finalized.height.0 as _
|
||||
);
|
||||
|
||||
block_result = Err(());
|
||||
}
|
||||
Err(())
|
||||
};
|
||||
|
||||
let _ = rsp_tx.send(result.map_err(Into::into));
|
||||
|
||||
|
|
Loading…
Reference in New Issue