From 02502f72f5a0f567424e97479f1dcf5159532ea1 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Tue, 12 Nov 2024 11:23:04 -0500 Subject: [PATCH] chore: clippy --- src/budgets.rs | 1 + src/indexers/cost_models.rs | 6 +++--- src/indexers/indexing_progress.rs | 6 +++--- src/indexers/public_poi.rs | 6 +++--- src/network/errors.rs | 4 +--- src/network/indexer_host_resolver.rs | 2 +- src/receipts.rs | 14 +++++++------- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/budgets.rs b/src/budgets.rs index 81202ee9a..4c51f653e 100644 --- a/src/budgets.rs +++ b/src/budgets.rs @@ -9,6 +9,7 @@ use tokio::{ use crate::metrics::METRICS; +#[allow(clippy::upper_case_acronyms)] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct USD(pub NotNan); diff --git a/src/indexers/cost_models.rs b/src/indexers/cost_models.rs index a762b9c71..860b0ae1e 100644 --- a/src/indexers/cost_models.rs +++ b/src/indexers/cost_models.rs @@ -22,7 +22,7 @@ const COST_MODEL_QUERY_DOCUMENT: &str = r#" pub enum Error { /// The request failed. #[error("request error: {0}")] - RequestError(String), + Request(String), /// Invalid response. /// @@ -50,14 +50,14 @@ pub async fn send_request( unreachable!("request serialization should not fail") } RequestError::RequestSendError(..) | RequestError::ResponseRecvError(..) => { - Error::RequestError(err.to_string()) + Error::Request(err.to_string()) } RequestError::ResponseDeserializationError { .. } => { Error::InvalidResponse(err.to_string()) } })? .map_err(|err| match err { - ResponseError::Failure { .. } => Error::RequestError(err.to_string()), + ResponseError::Failure { .. } => Error::Request(err.to_string()), ResponseError::Empty => Error::EmptyResponse, })?; diff --git a/src/indexers/indexing_progress.rs b/src/indexers/indexing_progress.rs index bc9c89674..bfa4447c8 100644 --- a/src/indexers/indexing_progress.rs +++ b/src/indexers/indexing_progress.rs @@ -25,7 +25,7 @@ const INDEXING_PROGRESS_QUERY_DOCUMENT: &str = r#" pub enum Error { /// The request failed. #[error("request error: {0}")] - RequestError(String), + Request(String), /// Invalid response. /// @@ -53,14 +53,14 @@ pub async fn send_request( unreachable!("request serialization should not fail") } RequestError::RequestSendError(..) | RequestError::ResponseRecvError(..) => { - Error::RequestError(err.to_string()) + Error::Request(err.to_string()) } RequestError::ResponseDeserializationError { .. } => { Error::InvalidResponse(err.to_string()) } })? .map_err(|err| match err { - ResponseError::Failure { .. } => Error::RequestError(err.to_string()), + ResponseError::Failure { .. } => Error::Request(err.to_string()), ResponseError::Empty => Error::EmptyResponse, })?; diff --git a/src/indexers/public_poi.rs b/src/indexers/public_poi.rs index 87889c5f6..a660d9181 100644 --- a/src/indexers/public_poi.rs +++ b/src/indexers/public_poi.rs @@ -22,7 +22,7 @@ const PUBLIC_PROOF_OF_INDEXING_QUERY_DOCUMENT: &str = r#" pub enum Error { /// The request failed. #[error("request error: {0}")] - RequestError(String), + Request(String), /// Invalid response. /// @@ -94,14 +94,14 @@ pub async fn send_request( unreachable!("request serialization should not fail") } RequestError::RequestSendError(..) | RequestError::ResponseRecvError(..) => { - Error::RequestError(err.to_string()) + Error::Request(err.to_string()) } RequestError::ResponseDeserializationError { .. } => { Error::InvalidResponse(err.to_string()) } })? .map_err(|err| match err { - ResponseError::Failure { .. } => Error::RequestError(err.to_string()), + ResponseError::Failure { .. } => Error::Request(err.to_string()), ResponseError::Empty => Error::EmptyResponse, })?; diff --git a/src/network/errors.rs b/src/network/errors.rs index d93c3ed61..6519fc57c 100644 --- a/src/network/errors.rs +++ b/src/network/errors.rs @@ -63,9 +63,7 @@ impl From for ResolutionError { let reason = match err { HostResolutionError::InvalidUrl(_) => "invalid indexer URL", - HostResolutionError::DnsResolutionError(_) => { - "indexer URL DNS resolution failed" - } + HostResolutionError::Dns(_) => "indexer URL DNS resolution failed", HostResolutionError::Timeout => { "indexer URL DNS resolution failed (timeout)" } diff --git a/src/network/indexer_host_resolver.rs b/src/network/indexer_host_resolver.rs index 14be82857..f41df9902 100644 --- a/src/network/indexer_host_resolver.rs +++ b/src/network/indexer_host_resolver.rs @@ -23,7 +23,7 @@ pub enum ResolutionError { /// /// This is a wrapper around [`ResolveError`]. #[error("dns resolution error: {0}")] - DnsResolutionError(#[from] ResolveError), + Dns(#[from] ResolveError), /// Resolution timed out. #[error("timeout")] diff --git a/src/receipts.rs b/src/receipts.rs index 18b65c6c7..2e600f507 100644 --- a/src/receipts.rs +++ b/src/receipts.rs @@ -15,7 +15,7 @@ use thegraph_core::{Address, AllocationId}; #[derive(Debug, Clone)] pub enum Receipt { Legacy(u128, Vec), - TAP(EIP712SignedMessage), + Tap(EIP712SignedMessage), } impl Receipt { @@ -23,7 +23,7 @@ impl Receipt { pub fn grt_value(&self) -> u128 { match self { Receipt::Legacy(value, _) => *value, - Receipt::TAP(receipt) => receipt.message.value, + Receipt::Tap(receipt) => receipt.message.value, } } @@ -31,7 +31,7 @@ impl Receipt { pub fn allocation(&self) -> Address { match self { Receipt::Legacy(_, receipt) => Address::from_slice(&receipt[0..20]), - Receipt::TAP(receipt) => receipt.message.allocation_id, + Receipt::Tap(receipt) => receipt.message.allocation_id, } } @@ -40,7 +40,7 @@ impl Receipt { pub fn serialize(&self) -> String { match self { Receipt::Legacy(_, receipt) => hex::encode(&receipt[..(receipt.len() - 32)]), - Receipt::TAP(receipt) => serde_json::to_string(&receipt).unwrap(), + Receipt::Tap(receipt) => serde_json::to_string(&receipt).unwrap(), } } @@ -49,7 +49,7 @@ impl Receipt { pub fn header_name(&self) -> &'static str { match self { Receipt::Legacy(_, _) => "Scalar-Receipt", - Receipt::TAP(_) => "Tap-Receipt", + Receipt::Tap(_) => "Tap-Receipt", } } } @@ -187,7 +187,7 @@ impl ReceiptSigner { /// Creates a new Scalar TAP receipt for the given allocation and fee. pub fn create_receipt(&self, allocation: AllocationId, fee: u128) -> anyhow::Result { - self.tap.create_receipt(allocation, fee).map(Receipt::TAP) + self.tap.create_receipt(allocation, fee).map(Receipt::Tap) } /// Creates a new Scalar legacy receipt for the given allocation and fee. @@ -352,6 +352,6 @@ mod tests { //* Then let receipt = res.expect("failed to create tap receipt"); - assert!(matches!(receipt, Receipt::TAP(_))); + assert!(matches!(receipt, Receipt::Tap(_))); } }