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: refactor some match with same arms #1463

Merged
merged 1 commit into from
Oct 16, 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
8 changes: 4 additions & 4 deletions crates/eips/src/eip4844/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ pub enum BlobTransactionValidationError {
impl std::error::Error for BlobTransactionValidationError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::InvalidProof { .. } => None,
Self::KZGError(source) => Some(source),
Self::NotBlobTransaction { .. } => None,
Self::MissingSidecar { .. } => None,
Self::WrongVersionedHash { .. } => None,
Self::InvalidProof { .. }
| Self::NotBlobTransaction { .. }
| Self::MissingSidecar { .. }
| Self::WrongVersionedHash { .. } => None,
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/provider/src/layers/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ impl<Params: RpcParam> RequestType<Params> {
const fn has_block_tag(&self) -> bool {
if let Some(block_id) = self.block_id {
match block_id {
BlockId::Hash(_) => return false,
BlockId::Number(BlockNumberOrTag::Number(_)) => return false,
BlockId::Hash(_) | BlockId::Number(BlockNumberOrTag::Number(_)) => return false,
_ => return true,
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/pubsub/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ impl ConnectionInterface {
/// requests.
pub async fn recv_from_frontend(&mut self) -> Option<Box<RawValue>> {
match self.shutdown.try_recv() {
Ok(_) => return None,
Err(TryRecvError::Closed) => return None,
Ok(_) | Err(TryRecvError::Closed) => return None,
Err(TryRecvError::Empty) => {}
}

Expand Down
17 changes: 7 additions & 10 deletions crates/rpc-types-engine/src/forkchoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,13 @@ impl From<ForkchoiceUpdateError> for jsonrpsee_types::error::ErrorObject<'static
None::<()>,
)
}
ForkchoiceUpdateError::InvalidState => jsonrpsee_types::error::ErrorObject::owned(
INVALID_FORK_CHOICE_STATE_ERROR,
INVALID_FORK_CHOICE_STATE_ERROR_MSG,
None::<()>,
),
ForkchoiceUpdateError::UnknownFinalBlock => jsonrpsee_types::error::ErrorObject::owned(
INVALID_FORK_CHOICE_STATE_ERROR,
INVALID_FORK_CHOICE_STATE_ERROR_MSG,
None::<()>,
),
ForkchoiceUpdateError::InvalidState | ForkchoiceUpdateError::UnknownFinalBlock => {
jsonrpsee_types::error::ErrorObject::owned(
INVALID_FORK_CHOICE_STATE_ERROR,
INVALID_FORK_CHOICE_STATE_ERROR_MSG,
None::<()>,
)
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc-types-engine/src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ impl std::error::Error for JwtError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::JwtSecretHexDecodeError(err) => Some(err),
Self::CreateDir { source, .. } => Some(source),
Self::Read { source, .. } => Some(source),
Self::Write { source, .. } => Some(source),
Self::CreateDir { source, .. }
| Self::Read { source, .. }
| Self::Write { source, .. } => Some(source),
_ => None,
}
}
Expand Down
10 changes: 5 additions & 5 deletions crates/rpc-types-eth/src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ impl std::error::Error for ConversionError {
match self {
Self::Eip2718Error(err) => Some(err),
Self::SignatureError(err) => Some(err),
Self::BaseFeePerGasConversion(err) => Some(err),
Self::GasLimitConversion(err) => Some(err),
Self::GasUsedConversion(err) => Some(err),
Self::BlobGasUsedConversion(err) => Some(err),
Self::ExcessBlobGasConversion(err) => Some(err),
Self::BaseFeePerGasConversion(err)
| Self::GasLimitConversion(err)
| Self::GasUsedConversion(err)
| Self::BlobGasUsedConversion(err)
| Self::ExcessBlobGasConversion(err) => Some(err),
_ => None,
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/rpc-types-trace/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ impl<Ok, Err> TraceResult<Ok, Err> {
#[doc(alias = "transaction_hash")]
pub const fn tx_hash(&self) -> Option<TxHash> {
*match self {
Self::Success { tx_hash, .. } => tx_hash,
Self::Error { tx_hash, .. } => tx_hash,
Self::Success { tx_hash, .. } | Self::Error { tx_hash, .. } => tx_hash,
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/rpc-types-txpool/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ impl<'de> Visitor<'de> for TxpoolInspectSummaryVisitor {
return Err(de::Error::custom("invalid format for TxpoolInspectSummary: gas_price"));
}
let to = match addr_split[0] {
"" => None,
"0x" => None,
"contract creation" => None,
"" | "0x" | "contract creation" => None,
addr => {
Some(Address::from_str(addr.trim_start_matches("0x")).map_err(de::Error::custom)?)
}
Expand Down
4 changes: 1 addition & 3 deletions crates/transport-ws/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ impl WsBackend<TungsteniteStream> {
error!("Received binary message, expected text");
Err(())
}
Message::Ping(_) => Ok(()),
Message::Pong(_) => Ok(()),
Message::Frame(_) => Ok(()),
Message::Ping(_) | Message::Pong(_) | Message::Frame(_) => Ok(()),
}
}

Expand Down