Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clippy): Cleanup nightly clippy warnings from 2023-10-30 #7868

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zebra-chain/src/orchard/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mod sinsemilla;
mod tree;

pub use group_hash::GROUP_HASHES;
pub use key_components::KEY_COMPONENTS;

pub use sinsemilla::SINSEMILLA;
pub use tree::{COMMITMENTS, EMPTY_ROOTS, ROOTS};
6 changes: 3 additions & 3 deletions zebra-consensus/src/block/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn coinbase_is_first(block: &Block) -> Result<Arc<transaction::Transaction>,
// <https://zips.z.cash/protocol/protocol.pdf#blockheader>
let first = block
.transactions
.get(0)
.first()
.ok_or(BlockError::NoTransactions)?;
// > The first transaction in a block MUST be a coinbase transaction,
// > and subsequent transactions MUST NOT be coinbase transactions.
Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn equihash_solution_is_valid(header: &Header) -> Result<(), equihash::Error
/// [3.9]: https://zips.z.cash/protocol/protocol.pdf#subsidyconcepts
pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockError> {
let height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
let coinbase = block.transactions.get(0).ok_or(SubsidyError::NoCoinbase)?;
let coinbase = block.transactions.first().ok_or(SubsidyError::NoCoinbase)?;

// Validate funding streams
let Some(halving_div) = subsidy::general::halving_divisor(height, network) else {
Expand Down Expand Up @@ -211,7 +211,7 @@ pub fn miner_fees_are_valid(
block_miner_fees: Amount<NonNegative>,
) -> Result<(), BlockError> {
let height = block.coinbase_height().ok_or(SubsidyError::NoCoinbase)?;
let coinbase = block.transactions.get(0).ok_or(SubsidyError::NoCoinbase)?;
let coinbase = block.transactions.first().ok_or(SubsidyError::NoCoinbase)?;

let transparent_value_balance: Amount = subsidy::general::output_amounts(coinbase)
.iter()
Expand Down
6 changes: 3 additions & 3 deletions zebra-consensus/src/block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static INVALID_COINBASE_TRANSCRIPT: Lazy<
assert_eq!(block3.transactions.len(), 1);

// Extract the coinbase transaction from the block
let coinbase_transaction = block3.transactions.get(0).unwrap().clone();
let coinbase_transaction = block3.transactions.first().unwrap().clone();

// Add another coinbase transaction to block
block3.transactions.push(coinbase_transaction);
Expand Down Expand Up @@ -373,7 +373,7 @@ fn coinbase_validation_failure() -> Result<(), Report> {
block.transactions.push(
block
.transactions
.get(0)
.first()
.expect("block has coinbase")
.clone(),
);
Expand Down Expand Up @@ -436,7 +436,7 @@ fn funding_stream_validation_failure() -> Result<(), Report> {
// Build the new transaction with modified coinbase outputs
let tx = block
.transactions
.get(0)
.first()
.map(|transaction| {
let mut output = transaction.outputs()[0].clone();
output.value = Amount::try_from(i32::MAX).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion zebra-consensus/src/transaction/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ fn coinbase_outputs_are_decryptable_for_historical_blocks_for_network(
.unwrap();
let coinbase_tx = block
.transactions
.get(0)
.first()
.expect("must have coinbase transaction");

// Check if the coinbase outputs are decryptable with an all-zero key.
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
.collect();

let parent_block = relevant_chain
.get(0)
.first()
.expect("state must contain parent block to do contextual validation");
let parent_block = parent_block.borrow();
let parent_height = parent_block
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/finalized_state/disk_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod upgrade;
#[cfg(test)]
mod tests;

pub use block::{TransactionIndex, TransactionLocation, MAX_ON_DISK_HEIGHT};
pub use block::{TransactionLocation, MAX_ON_DISK_HEIGHT};
pub use transparent::{OutputIndex, OutputLocation};

/// Helper type for writing types to disk as raw bytes.
Expand Down
12 changes: 6 additions & 6 deletions zebra-state/src/service/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ mod tests;
pub use address::{
balance::transparent_balance,
tx_id::transparent_tx_ids,
utxo::{address_utxos, AddressUtxos, ADDRESS_HEIGHTS_FULL_RANGE},
utxo::{address_utxos, AddressUtxos},
};
pub use block::{
any_utxo, block, block_header, mined_transaction, transaction_hashes_for_block, unspent_utxo,
utxo,
};
pub use find::{
best_tip, block_locator, chain_contains_hash, depth, finalized_state_contains_block_hash,
find_chain_hashes, find_chain_headers, hash_by_height, height_by_hash, next_median_time_past,
best_tip, block_locator, depth, finalized_state_contains_block_hash, find_chain_hashes,
find_chain_headers, hash_by_height, height_by_hash, next_median_time_past,
non_finalized_state_contains_block_hash, tip, tip_height,
};
pub use tree::{orchard_subtrees, orchard_tree, sapling_subtrees, sapling_tree};

#[cfg(feature = "getblocktemplate-rpcs")]
pub use difficulty::get_block_template_chain_info;
#[cfg(any(test, feature = "proptest-impl"))]
#[allow(unused_imports)]
pub use address::utxo::ADDRESS_HEIGHTS_FULL_RANGE;

/// If a finalized state query is interrupted by a new finalized block,
/// retry this many times.
Expand Down
8 changes: 4 additions & 4 deletions zebra-state/src/service/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,20 @@ async fn test_populated_state_responds_correctly(
transcript.push((
Request::FindBlockHashes {
known_blocks: known_hashes.iter().rev().cloned().collect(),
stop: next_hashes.get(0).cloned(),
stop: next_hashes.first().cloned(),
},
Ok(Response::BlockHashes(
next_hashes.get(0).iter().cloned().cloned().collect(),
next_hashes.first().iter().cloned().cloned().collect(),
)),
));

transcript.push((
Request::FindBlockHeaders {
known_blocks: known_hashes.iter().rev().cloned().collect(),
stop: next_hashes.get(0).cloned(),
stop: next_hashes.first().cloned(),
},
Ok(Response::BlockHeaders(
next_headers.get(0).iter().cloned().cloned().collect(),
next_headers.first().iter().cloned().cloned().collect(),
)),
));

Expand Down
Loading