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: Fix clippy lints #9062

Merged
merged 2 commits into from
Nov 29, 2024
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: 2 additions & 0 deletions tower-fallback/tests/fallback.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Tests for tower-fallback

use tower::{service_fn, Service, ServiceExt};
use tower_fallback::Fallback;

Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/chain_tip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'f> BestTipChanged<'f> {
}
}

impl<'f> Future for BestTipChanged<'f> {
impl Future for BestTipChanged<'_> {
type Output = Result<(), BoxError>;

fn poll(
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/orchard/shielded_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,6 @@ impl ZcashDeserialize for Flags {
// the reserved bits 2..7 of the flagsOrchard field MUST be zero."
// https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
Flags::from_bits(reader.read_u8()?)
.ok_or_else(|| SerializationError::Parse("invalid reserved orchard flags"))
.ok_or(SerializationError::Parse("invalid reserved orchard flags"))
}
}
2 changes: 2 additions & 0 deletions zebra-chain/src/serialization/tests.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//! Serialization tests.

mod preallocate;
mod prop;
2 changes: 1 addition & 1 deletion zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl Transaction {
&'a self,
branch_id: ConsensusBranchId,
all_previous_outputs: &'a [transparent::Output],
) -> sighash::SigHasher {
) -> sighash::SigHasher<'a> {
sighash::SigHasher::new(self, branch_id, all_previous_outputs)
}

Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/transaction/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ impl ZcashDeserialize for Transaction {
// Convert it to a NetworkUpgrade
let network_upgrade =
NetworkUpgrade::from_branch_id(limited_reader.read_u32::<LittleEndian>()?)
.ok_or_else(|| {
.ok_or({
SerializationError::Parse(
"expected a valid network upgrade from the consensus branch id",
)
Expand Down
4 changes: 3 additions & 1 deletion zebra-network/src/protocol/external/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ impl Codec {
timestamp: Utc
.timestamp_opt(reader.read_i64::<LittleEndian>()?, 0)
.single()
.ok_or_else(|| Error::Parse("version timestamp is out of range for DateTime"))?,
.ok_or(Error::Parse(
"version timestamp is out of range for DateTime",
))?,
address_recv: AddrInVersion::zcash_deserialize(&mut reader)?,
address_from: AddrInVersion::zcash_deserialize(&mut reader)?,
nonce: Nonce(reader.read_u64::<LittleEndian>()?),
Expand Down
24 changes: 12 additions & 12 deletions zebra-scan/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ impl Service<Request> for ScanService {
Request::Info => {
let db = self.db.clone();

return async move {
async move {
Ok(Response::Info {
min_sapling_birthday_height: db.network().sapling_activation_height(),
})
}
.boxed();
.boxed()
}

Request::RegisterKeys(keys) => {
let mut scan_task = self.scan_task.clone();

return async move {
async move {
let newly_registered_keys = scan_task.register_keys(keys)?.await?;
if !newly_registered_keys.is_empty() {
Ok(Response::RegisteredKeys(newly_registered_keys))
Expand All @@ -113,14 +113,14 @@ impl Service<Request> for ScanService {
are valid Sapling extended full viewing keys".into())
}
}
.boxed();
.boxed()
}

Request::DeleteKeys(keys) => {
let mut db = self.db.clone();
let mut scan_task = self.scan_task.clone();

return async move {
async move {
// Wait for a message to confirm that the scan task has removed the key up to `DELETE_KEY_TIMEOUT`
let remove_keys_result = tokio::time::timeout(
DELETE_KEY_TIMEOUT,
Expand All @@ -141,13 +141,13 @@ impl Service<Request> for ScanService {

Ok(Response::DeletedKeys)
}
.boxed();
.boxed()
}

Request::Results(keys) => {
let db = self.db.clone();

return async move {
async move {
let mut final_result = BTreeMap::new();
for key in keys {
let db = db.clone();
Expand All @@ -168,26 +168,26 @@ impl Service<Request> for ScanService {

Ok(Response::Results(final_result))
}
.boxed();
.boxed()
}

Request::SubscribeResults(keys) => {
let mut scan_task = self.scan_task.clone();

return async move {
async move {
let results_receiver = scan_task.subscribe(keys)?.await.map_err(|_| {
"scan task dropped responder, check that keys are registered"
})?;

Ok(Response::SubscribeResults(results_receiver))
}
.boxed();
.boxed()
}

Request::ClearResults(keys) => {
let mut db = self.db.clone();

return async move {
async move {
// Clear results from db for the provided `keys`
tokio::task::spawn_blocking(move || {
db.delete_sapling_results(keys);
Expand All @@ -196,7 +196,7 @@ impl Service<Request> for ScanService {

Ok(Response::ClearedResults)
}
.boxed();
.boxed()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions zebra-scan/src/storage/db/sapling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ trait InsertSaplingHeight {
fn insert_sapling_height(self, sapling_key: &SaplingScanningKey, height: Height) -> Self;
}

impl<'cf> InsertSaplingHeight for WriteSaplingTxIdsBatch<'cf> {
impl InsertSaplingHeight for WriteSaplingTxIdsBatch<'_> {
/// Insert sapling height with no results.
///
/// If a result already exists for the coinbase transaction at that height,
Expand All @@ -283,7 +283,7 @@ trait DeleteSaplingKeys {
fn delete_sapling_keys(self, sapling_key: Vec<SaplingScanningKey>) -> Self;
}

impl<'cf> DeleteSaplingKeys for WriteSaplingTxIdsBatch<'cf> {
impl DeleteSaplingKeys for WriteSaplingTxIdsBatch<'_> {
/// Delete sapling keys and their results.
fn delete_sapling_keys(mut self, sapling_keys: Vec<SaplingScanningKey>) -> Self {
for key in &sapling_keys {
Expand Down
4 changes: 3 additions & 1 deletion zebra-scan/tests/scan_task_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//!
//! export ZEBRA_CACHED_STATE_DIR="/path/to/zebra/state"
//! cargo test scan_task_commands --features="shielded-scan" -- --ignored --nocapture
#![allow(dead_code)]
#![allow(dead_code, non_local_definitions)]

use std::{fs, time::Duration};

Expand All @@ -26,6 +26,7 @@ use zebra_scan::{

use zebra_state::{ChainTipChange, LatestChainTip};

/// Boxed state service.
pub type BoxStateService =
BoxService<zebra_state::Request, zebra_state::Response, zebra_state::BoxError>;

Expand Down Expand Up @@ -162,6 +163,7 @@ pub(crate) async fn run() -> Result<()> {
Ok(())
}

/// Starts the state service with the provided cache directory.
pub async fn start_state_service_with_cache_dir(
network: &Network,
cache_dir: impl Into<std::path::PathBuf>,
Expand Down
14 changes: 7 additions & 7 deletions zebra-state/src/service/finalized_state/column_family.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
batch: Batch,
}

impl<'cf, Key, Value> Debug for TypedColumnFamily<'cf, Key, Value>
impl<Key, Value> Debug for TypedColumnFamily<'_, Key, Value>
where
Key: IntoDisk + FromDisk + Debug,
Value: IntoDisk + FromDisk,
Expand All @@ -80,7 +80,7 @@ where
}
}

impl<'cf, Key, Value> PartialEq for TypedColumnFamily<'cf, Key, Value>
impl<Key, Value> PartialEq for TypedColumnFamily<'_, Key, Value>
where
Key: IntoDisk + FromDisk + Debug,
Value: IntoDisk + FromDisk,
Expand All @@ -90,7 +90,7 @@ where
}
}

impl<'cf, Key, Value> Eq for TypedColumnFamily<'cf, Key, Value>
impl<Key, Value> Eq for TypedColumnFamily<'_, Key, Value>
where
Key: IntoDisk + FromDisk + Debug,
Value: IntoDisk + FromDisk,
Expand Down Expand Up @@ -243,7 +243,7 @@ where
}
}

impl<'cf, Key, Value> TypedColumnFamily<'cf, Key, Value>
impl<Key, Value> TypedColumnFamily<'_, Key, Value>
where
Key: IntoDisk + FromDisk + Debug + Ord,
Value: IntoDisk + FromDisk,
Expand All @@ -259,7 +259,7 @@ where
}
}

impl<'cf, Key, Value> TypedColumnFamily<'cf, Key, Value>
impl<Key, Value> TypedColumnFamily<'_, Key, Value>
where
Key: IntoDisk + FromDisk + Debug + Hash + Eq,
Value: IntoDisk + FromDisk,
Expand All @@ -275,7 +275,7 @@ where
}
}

impl<'cf, Key, Value, Batch> WriteTypedBatch<'cf, Key, Value, Batch>
impl<Key, Value, Batch> WriteTypedBatch<'_, Key, Value, Batch>
where
Key: IntoDisk + FromDisk + Debug,
Value: IntoDisk + FromDisk,
Expand Down Expand Up @@ -312,7 +312,7 @@ where
}

// Writing a batch to the database requires an owned batch.
impl<'cf, Key, Value> WriteTypedBatch<'cf, Key, Value, DiskWriteBatch>
impl<Key, Value> WriteTypedBatch<'_, Key, Value, DiskWriteBatch>
where
Key: IntoDisk + FromDisk + Debug,
Value: IntoDisk + FromDisk,
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 @@ -68,7 +68,7 @@ pub trait FromDisk: Sized {

// Generic serialization impls

impl<'a, T> IntoDisk for &'a T
impl<T> IntoDisk for &T
where
T: IntoDisk,
{
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/non_finalized_state/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ impl Chain {
pub fn partial_transparent_indexes<'a>(
&'a self,
addresses: &'a HashSet<transparent::Address>,
) -> impl Iterator<Item = &TransparentTransfers> {
) -> impl Iterator<Item = &'a TransparentTransfers> {
addresses
.iter()
.flat_map(|address| self.partial_transparent_transfers.get(address))
Expand Down
2 changes: 2 additions & 0 deletions zebrad/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Zebrad Subcommands

#![allow(non_local_definitions)]

use std::path::PathBuf;

use abscissa_core::{config::Override, Command, Configurable, FrameworkError, Runnable};
Expand Down
2 changes: 2 additions & 0 deletions zebrad/src/components/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! An HTTP endpoint for metrics collection.

#![allow(non_local_definitions)]

use std::net::SocketAddr;

use abscissa_core::{Component, FrameworkError};
Expand Down
2 changes: 2 additions & 0 deletions zebrad/src/components/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! The rayon thread pool is used for:
//! - long-running CPU-bound tasks like cryptography, via [`rayon::spawn_fifo`].

#![allow(non_local_definitions)]

use std::{future::Future, time::Duration};

use abscissa_core::{Component, FrameworkError, Shutdown};
Expand Down
2 changes: 2 additions & 0 deletions zebrad/src/components/tracing/endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! An HTTP endpoint for dynamically setting tracing filters.

#![allow(non_local_definitions)]

use std::net::SocketAddr;

use abscissa_core::{Component, FrameworkError};
Expand Down
Loading