chore: fix unnameable-types lint on blockchain-tree and rpc crates (#9757)

Co-authored-by: Emilia Hane <emiliaha95@gmail.com>
This commit is contained in:
Tuan Tran
2024-07-25 22:31:20 +07:00
committed by GitHub
parent 22a25caed8
commit db8706e5d8
8 changed files with 28 additions and 15 deletions

View File

@ -63,7 +63,8 @@ impl BlockIndices {
} }
/// Return block to chain id /// Return block to chain id
pub const fn blocks_to_chain(&self) -> &HashMap<BlockHash, BlockchainId> { #[allow(dead_code)]
pub(crate) const fn blocks_to_chain(&self) -> &HashMap<BlockHash, BlockchainId> {
&self.blocks_to_chain &self.blocks_to_chain
} }
@ -202,7 +203,7 @@ impl BlockIndices {
/// Remove chain from indices and return dependent chains that need to be removed. /// Remove chain from indices and return dependent chains that need to be removed.
/// Does the cleaning of the tree and removing blocks from the chain. /// Does the cleaning of the tree and removing blocks from the chain.
pub fn remove_chain(&mut self, chain: &Chain) -> BTreeSet<BlockchainId> { pub(crate) fn remove_chain(&mut self, chain: &Chain) -> BTreeSet<BlockchainId> {
chain chain
.blocks() .blocks()
.iter() .iter()

View File

@ -113,7 +113,7 @@ impl TreeState {
/// The ID of a sidechain internally in a [`BlockchainTree`][super::BlockchainTree]. /// The ID of a sidechain internally in a [`BlockchainTree`][super::BlockchainTree].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct BlockchainId(u64); pub(crate) struct BlockchainId(u64);
impl From<BlockchainId> for u64 { impl From<BlockchainId> for u64 {
fn from(value: BlockchainId) -> Self { fn from(value: BlockchainId) -> Self {

View File

@ -32,10 +32,7 @@ use tower::{layer::util::Identity, Layer, Service};
use tracing::{debug, instrument, trace, warn, Instrument}; use tracing::{debug, instrument, trace, warn, Instrument};
// re-export so can be used during builder setup // re-export so can be used during builder setup
use crate::{ use crate::{
server::{ server::{connection::IpcConnDriver, rpc_service::RpcServiceCfg},
connection::IpcConnDriver,
rpc_service::{RpcService, RpcServiceCfg},
},
stream_codec::StreamCodec, stream_codec::StreamCodec,
}; };
use tokio::sync::mpsc; use tokio::sync::mpsc;
@ -46,6 +43,8 @@ mod connection;
mod ipc; mod ipc;
mod rpc_service; mod rpc_service;
pub use rpc_service::RpcService;
/// Ipc Server implementation /// Ipc Server implementation
/// ///
/// This is an adapted `jsonrpsee` Server, but for `Ipc` connections. /// This is an adapted `jsonrpsee` Server, but for `Ipc` connections.

View File

@ -4,10 +4,19 @@ use tower_http::cors::{AllowOrigin, Any, CorsLayer};
/// Error thrown when parsing cors domains went wrong /// Error thrown when parsing cors domains went wrong
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum CorsDomainError { pub enum CorsDomainError {
/// Represents an invalid header value for a domain
#[error("{domain} is an invalid header value")] #[error("{domain} is an invalid header value")]
InvalidHeader { domain: String }, InvalidHeader {
/// The domain that caused the invalid header
domain: String,
},
/// Indicates that a wildcard origin was used incorrectly in a list
#[error("wildcard origin (`*`) cannot be passed as part of a list: {input}")] #[error("wildcard origin (`*`) cannot be passed as part of a list: {input}")]
WildCardNotAllowed { input: String }, WildCardNotAllowed {
/// The input string containing the incorrectly used wildcard
input: String,
},
} }
/// Creates a [`CorsLayer`] from the given domains /// Creates a [`CorsLayer`] from the given domains

View File

@ -177,12 +177,9 @@ use serde::{Deserialize, Serialize};
use tower::Layer; use tower::Layer;
use tower_http::cors::CorsLayer; use tower_http::cors::CorsLayer;
use crate::{ use crate::{auth::AuthRpcModule, error::WsHttpSamePortError, metrics::RpcRequestMetrics};
auth::AuthRpcModule,
cors::CorsDomainError, pub use cors::CorsDomainError;
error::WsHttpSamePortError,
metrics::{RpcRequestMetrics, RpcRequestMetricsService},
};
// re-export for convenience // re-export for convenience
pub use jsonrpsee::server::ServerBuilder; pub use jsonrpsee::server::ServerBuilder;
@ -210,6 +207,7 @@ pub use eth::EthHandlers;
// Rpc server metrics // Rpc server metrics
mod metrics; mod metrics;
pub use metrics::{MeteredRequestFuture, RpcRequestMetricsService};
/// Convenience function for starting a server in one step. /// Convenience function for starting a server in one step.
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]

View File

@ -83,7 +83,9 @@ struct RpcServerMetricsInner {
/// This is created per connection and captures metrics for each request. /// This is created per connection and captures metrics for each request.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct RpcRequestMetricsService<S> { pub struct RpcRequestMetricsService<S> {
/// The metrics collector for RPC requests
metrics: RpcRequestMetrics, metrics: RpcRequestMetrics,
/// The inner service being wrapped
inner: S, inner: S,
} }

View File

@ -102,9 +102,11 @@ where
} }
} }
/// A future representing the response of an RPC request
#[pin_project] #[pin_project]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct ResponseFuture<F> { pub struct ResponseFuture<F> {
/// The kind of response future, error or pending
#[pin] #[pin]
kind: Kind<F>, kind: Kind<F>,
} }

View File

@ -15,6 +15,8 @@ mod auth_client_layer;
mod auth_layer; mod auth_layer;
mod jwt_validator; mod jwt_validator;
pub use auth_layer::{AuthService, ResponseFuture};
// Export alloy JWT types // Export alloy JWT types
pub use alloy_rpc_types_engine::{Claims, JwtError, JwtSecret}; pub use alloy_rpc_types_engine::{Claims, JwtError, JwtSecret};