mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
clippy: add unnested_or_patterns clippy lint (#10526)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
@ -209,6 +209,7 @@ tuple_array_conversions = "warn"
|
||||
type_repetition_in_bounds = "warn"
|
||||
uninhabited_references = "warn"
|
||||
unnecessary_struct_initialization = "warn"
|
||||
unnested_or_patterns = "warn"
|
||||
unused_peekable = "warn"
|
||||
unused_rounding = "warn"
|
||||
use_self = "warn"
|
||||
|
||||
@ -277,7 +277,7 @@ fn parse_metrics_attr(node: &DeriveInput) -> Result<MetricsAttr> {
|
||||
}
|
||||
|
||||
let scope = match (scope, dynamic) {
|
||||
(Some(scope), None) | (Some(scope), Some(false)) => MetricsScope::Static(scope),
|
||||
(Some(scope), None | Some(false)) => MetricsScope::Static(scope),
|
||||
(None, Some(true)) => MetricsScope::Dynamic,
|
||||
(Some(_), Some(_)) => {
|
||||
return Err(Error::new_spanned(node, "`scope = ..` conflicts with `dynamic = true`."))
|
||||
|
||||
@ -111,9 +111,7 @@ impl SessionError for EthStreamError {
|
||||
fn merits_discovery_ban(&self) -> bool {
|
||||
match self {
|
||||
Self::P2PStreamError(P2PStreamError::HandshakeError(
|
||||
P2PHandshakeError::HelloNotInHandshake,
|
||||
)) |
|
||||
Self::P2PStreamError(P2PStreamError::HandshakeError(
|
||||
P2PHandshakeError::HelloNotInHandshake |
|
||||
P2PHandshakeError::NonHelloMessageInHandshake,
|
||||
)) => true,
|
||||
Self::EthHandshakeError(err) => !matches!(err, EthHandshakeError::NoResponse),
|
||||
@ -126,29 +124,24 @@ impl SessionError for EthStreamError {
|
||||
Self::P2PStreamError(err) => {
|
||||
matches!(
|
||||
err,
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::NoSharedCapabilities) |
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::HelloNotInHandshake) |
|
||||
P2PStreamError::HandshakeError(
|
||||
P2PHandshakeError::NonHelloMessageInHandshake
|
||||
) |
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
|
||||
DisconnectReason::UselessPeer
|
||||
)) |
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
|
||||
DisconnectReason::IncompatibleP2PProtocolVersion
|
||||
)) |
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::Disconnected(
|
||||
DisconnectReason::ProtocolBreach
|
||||
)) |
|
||||
P2PStreamError::UnknownReservedMessageId(_) |
|
||||
P2PStreamError::HandshakeError(
|
||||
P2PHandshakeError::NoSharedCapabilities |
|
||||
P2PHandshakeError::HelloNotInHandshake |
|
||||
P2PHandshakeError::NonHelloMessageInHandshake |
|
||||
P2PHandshakeError::Disconnected(
|
||||
DisconnectReason::UselessPeer |
|
||||
DisconnectReason::IncompatibleP2PProtocolVersion |
|
||||
DisconnectReason::ProtocolBreach
|
||||
)
|
||||
) | P2PStreamError::UnknownReservedMessageId(_) |
|
||||
P2PStreamError::EmptyProtocolMessage |
|
||||
P2PStreamError::ParseSharedCapability(_) |
|
||||
P2PStreamError::CapabilityNotShared |
|
||||
P2PStreamError::Disconnected(DisconnectReason::UselessPeer) |
|
||||
P2PStreamError::Disconnected(
|
||||
DisconnectReason::IncompatibleP2PProtocolVersion
|
||||
DisconnectReason::UselessPeer |
|
||||
DisconnectReason::IncompatibleP2PProtocolVersion |
|
||||
DisconnectReason::ProtocolBreach
|
||||
) |
|
||||
P2PStreamError::Disconnected(DisconnectReason::ProtocolBreach) |
|
||||
P2PStreamError::MismatchedProtocolVersion { .. }
|
||||
)
|
||||
}
|
||||
@ -190,16 +183,20 @@ impl SessionError for EthStreamError {
|
||||
match self {
|
||||
// timeouts
|
||||
Self::EthHandshakeError(EthHandshakeError::NoResponse) |
|
||||
Self::P2PStreamError(P2PStreamError::HandshakeError(P2PHandshakeError::NoResponse)) |
|
||||
Self::P2PStreamError(P2PStreamError::PingTimeout) => Some(BackoffKind::Low),
|
||||
Self::P2PStreamError(
|
||||
P2PStreamError::HandshakeError(P2PHandshakeError::NoResponse) |
|
||||
P2PStreamError::PingTimeout,
|
||||
) => Some(BackoffKind::Low),
|
||||
// malformed messages
|
||||
Self::P2PStreamError(P2PStreamError::Rlp(_)) |
|
||||
Self::P2PStreamError(P2PStreamError::UnknownReservedMessageId(_)) |
|
||||
Self::P2PStreamError(P2PStreamError::UnknownDisconnectReason(_)) |
|
||||
Self::P2PStreamError(P2PStreamError::MessageTooBig { .. }) |
|
||||
Self::P2PStreamError(P2PStreamError::EmptyProtocolMessage) |
|
||||
Self::P2PStreamError(P2PStreamError::PingerError(_)) |
|
||||
Self::P2PStreamError(P2PStreamError::Snap(_)) => Some(BackoffKind::Medium),
|
||||
Self::P2PStreamError(
|
||||
P2PStreamError::Rlp(_) |
|
||||
P2PStreamError::UnknownReservedMessageId(_) |
|
||||
P2PStreamError::UnknownDisconnectReason(_) |
|
||||
P2PStreamError::MessageTooBig { .. } |
|
||||
P2PStreamError::EmptyProtocolMessage |
|
||||
P2PStreamError::PingerError(_) |
|
||||
P2PStreamError::Snap(_),
|
||||
) => Some(BackoffKind::Medium),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,10 +117,8 @@ impl From<EngineApiError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
fn from(error: EngineApiError) -> Self {
|
||||
match error {
|
||||
EngineApiError::InvalidBodiesRange { .. } |
|
||||
EngineApiError::EngineObjectValidationError(EngineObjectValidationError::Payload(
|
||||
_,
|
||||
)) |
|
||||
EngineApiError::EngineObjectValidationError(
|
||||
EngineObjectValidationError::Payload(_) |
|
||||
EngineObjectValidationError::InvalidParams(_),
|
||||
) => {
|
||||
// Note: the data field is not required by the spec, but is also included by other
|
||||
|
||||
@ -181,7 +181,7 @@ impl From<EthApiError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
jsonrpsee_types::error::CALL_EXECUTION_FAILED_CODE,
|
||||
err.to_string(),
|
||||
),
|
||||
err @ EthApiError::InternalBlockingTaskError | err @ EthApiError::InternalEthError => {
|
||||
err @ (EthApiError::InternalBlockingTaskError | EthApiError::InternalEthError) => {
|
||||
internal_rpc_err(err.to_string())
|
||||
}
|
||||
err @ EthApiError::TransactionInputError(_) => invalid_params_rpc_err(err.to_string()),
|
||||
|
||||
@ -45,9 +45,9 @@ impl From<EthFilterError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
rpc_error_with_code(jsonrpsee_types::error::INTERNAL_ERROR_CODE, err.to_string())
|
||||
}
|
||||
EthFilterError::EthAPIError(err) => err.into(),
|
||||
err @ EthFilterError::InvalidBlockRangeParams |
|
||||
err @ EthFilterError::QueryExceedsMaxBlocks(_) |
|
||||
err @ EthFilterError::QueryExceedsMaxResults(_) => {
|
||||
err @ (EthFilterError::InvalidBlockRangeParams |
|
||||
EthFilterError::QueryExceedsMaxBlocks(_) |
|
||||
EthFilterError::QueryExceedsMaxResults(_)) => {
|
||||
rpc_error_with_code(jsonrpsee_types::error::INVALID_PARAMS_CODE, err.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,10 +146,10 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
std::mem::swap(&mut self.all_transactions.pending_fees.blob_fee, &mut pending_blob_fee);
|
||||
match (self.all_transactions.pending_fees.blob_fee.cmp(&pending_blob_fee), base_fee_update)
|
||||
{
|
||||
(Ordering::Equal, Ordering::Equal) | (Ordering::Equal, Ordering::Greater) => {
|
||||
(Ordering::Equal, Ordering::Equal | Ordering::Greater) => {
|
||||
// fee unchanged, nothing to update
|
||||
}
|
||||
(Ordering::Greater, Ordering::Equal) | (Ordering::Greater, Ordering::Greater) => {
|
||||
(Ordering::Greater, Ordering::Equal | Ordering::Greater) => {
|
||||
// increased blob fee: recheck pending pool and remove all that are no longer valid
|
||||
let removed =
|
||||
self.pending_pool.update_blob_fee(self.all_transactions.pending_fees.blob_fee);
|
||||
|
||||
Reference in New Issue
Block a user