From c71e57d13c55b7c7f5fdcb055c1568fa35398ff0 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Sat, 16 Dec 2023 13:31:35 -0300 Subject: [PATCH] chore: fix lint warnings --- src/filters/selection.rs | 33 ++++++++++++++++++--------------- src/model.rs | 2 +- src/sources/n2c/run.rs | 4 ++-- src/sources/n2n/run.rs | 4 ++-- src/utils/facade.rs | 4 ++-- src/utils/metrics.rs | 3 ++- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/filters/selection.rs b/src/filters/selection.rs index 2b033f73..2000d164 100644 --- a/src/filters/selection.rs +++ b/src/filters/selection.rs @@ -157,11 +157,12 @@ fn metadata_any_sub_label_matches(event: &Event, sub_label: &str) -> bool { fn vkey_witnesses_matches(event: &Event, witness: &str) -> bool { match &event.data { EventData::VKeyWitness(x) => x.vkey_hex == witness, - EventData::Transaction(x) => - x.vkey_witnesses.as_ref() - .map(|vs| vs.iter().any(|v| v.vkey_hex == witness)) - .unwrap_or(false), - _ => false + EventData::Transaction(x) => x + .vkey_witnesses + .as_ref() + .map(|vs| vs.iter().any(|v| v.vkey_hex == witness)) + .unwrap_or(false), + _ => false, } } @@ -169,11 +170,12 @@ fn vkey_witnesses_matches(event: &Event, witness: &str) -> bool { fn native_scripts_matches(event: &Event, policy_id: &str) -> bool { match &event.data { EventData::NativeWitness(x) => x.policy_id == policy_id, - EventData::Transaction(x) => - x.native_witnesses.as_ref() - .map(|vs| vs.iter().any(|v| v.policy_id == policy_id)) - .unwrap_or(false), - _ => false + EventData::Transaction(x) => x + .native_witnesses + .as_ref() + .map(|vs| vs.iter().any(|v| v.policy_id == policy_id)) + .unwrap_or(false), + _ => false, } } @@ -181,11 +183,12 @@ fn native_scripts_matches(event: &Event, policy_id: &str) -> bool { fn plutus_scripts_matches(event: &Event, script_hash: &str) -> bool { match &event.data { EventData::PlutusWitness(x) => x.script_hash == script_hash, - EventData::Transaction(x) => - x.plutus_witnesses.as_ref() - .map(|vs| vs.iter().any(|v| v.script_hash == script_hash)) - .unwrap_or(false), - _ => false + EventData::Transaction(x) => x + .plutus_witnesses + .as_ref() + .map(|vs| vs.iter().any(|v| v.script_hash == script_hash)) + .unwrap_or(false), + _ => false, } } diff --git a/src/model.rs b/src/model.rs index 9a0937e7..ad661bc3 100644 --- a/src/model.rs +++ b/src/model.rs @@ -412,7 +412,7 @@ impl<'de> Visitor<'de> for IntScalarVisitor { where E: serde::de::Error, { - Ok(v.parse().map_err(DeError::custom)?) + v.parse().map_err(DeError::custom) } fn visit_u64(self, v: u64) -> Result diff --git a/src/sources/n2c/run.rs b/src/sources/n2c/run.rs index efa696ee..a6aef999 100644 --- a/src/sources/n2c/run.rs +++ b/src/sources/n2c/run.rs @@ -205,7 +205,7 @@ fn do_chainsync_attempt( }; let mut plexer = setup_multiplexer(&config.address.0, &config.address.1, &config.retry_policy) - .map_err(|x| AttemptError::Recoverable(x))?; + .map_err(AttemptError::Recoverable)?; let hs_channel = plexer.use_channel(0); let cs_channel = plexer.use_channel(5); @@ -224,7 +224,7 @@ fn do_chainsync_attempt( &config.since, &utils, ) - .map_err(|err| AttemptError::Recoverable(err))?; + .map_err(AttemptError::Recoverable)?; if intersection.is_none() { return Err(AttemptError::Other( diff --git a/src/sources/n2n/run.rs b/src/sources/n2n/run.rs index a3956d8e..f2b83267 100644 --- a/src/sources/n2n/run.rs +++ b/src/sources/n2n/run.rs @@ -211,7 +211,7 @@ fn do_chainsync_attempt( }; let mut plexer = setup_multiplexer(&config.address.0, &config.address.1, &config.retry_policy) - .map_err(|x| AttemptError::Recoverable(x))?; + .map_err(AttemptError::Recoverable)?; let hs_channel = plexer.use_channel(0); let cs_channel = plexer.use_channel(2); @@ -231,7 +231,7 @@ fn do_chainsync_attempt( &config.since, &utils, ) - .map_err(|err| AttemptError::Recoverable(err))?; + .map_err(AttemptError::Recoverable)?; if intersection.is_none() { return Err(AttemptError::Other( diff --git a/src/utils/facade.rs b/src/utils/facade.rs index c0159671..5e485012 100644 --- a/src/utils/facade.rs +++ b/src/utils/facade.rs @@ -1,6 +1,6 @@ -use super::*; +//! A friendly facade to simplify access to common utils procedures -///! A friendly facade to simplify access to common utils procedures +use super::*; impl Utils { // To be used by source stages to access the cursor, if any diff --git a/src/utils/metrics.rs b/src/utils/metrics.rs index 57093d6b..ab4f1088 100644 --- a/src/utils/metrics.rs +++ b/src/utils/metrics.rs @@ -1,4 +1,5 @@ -///! An utility to keep track of the progress of the pipeline as a whole +//! An utility to keep track of the progress of the pipeline as a whole + use prometheus_exporter::prometheus::{register_counter, register_int_gauge, Counter, IntGauge}; use merge::Merge;