mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat: make payload builder generic over attributes type (#5948)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -11,6 +11,7 @@ use jsonrpsee::{
|
||||
server::{RpcModule, ServerHandle},
|
||||
};
|
||||
use reth_network_api::{NetworkInfo, Peers};
|
||||
use reth_node_api::EngineTypes;
|
||||
use reth_provider::{
|
||||
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, ReceiptProviderIdExt,
|
||||
StateProviderFactory,
|
||||
@@ -33,7 +34,7 @@ use std::{
|
||||
|
||||
/// Configure and launch a _standalone_ auth server with `engine` and a _new_ `eth` namespace.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn launch<Provider, Pool, Network, Tasks, EngineApi>(
|
||||
pub async fn launch<Provider, Pool, Network, Tasks, EngineApi, EngineT>(
|
||||
provider: Provider,
|
||||
pool: Pool,
|
||||
network: Network,
|
||||
@@ -55,7 +56,8 @@ where
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
EngineApi: EngineApiServer,
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
{
|
||||
// spawn a new cache task
|
||||
let eth_cache =
|
||||
@@ -85,7 +87,7 @@ where
|
||||
}
|
||||
|
||||
/// Configure and launch a _standalone_ auth server with existing EthApi implementation.
|
||||
pub async fn launch_with_eth_api<Provider, Pool, Network, EngineApi>(
|
||||
pub async fn launch_with_eth_api<Provider, Pool, Network, EngineApi, EngineT>(
|
||||
eth_api: EthApi<Provider, Pool, Network>,
|
||||
eth_filter: EthFilter<Provider, Pool>,
|
||||
engine_api: EngineApi,
|
||||
@@ -103,7 +105,8 @@ where
|
||||
+ 'static,
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
EngineApi: EngineApiServer,
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
{
|
||||
// Configure the module and start the server.
|
||||
let mut module = RpcModule::new(());
|
||||
@@ -253,9 +256,10 @@ pub struct AuthRpcModule {
|
||||
|
||||
impl AuthRpcModule {
|
||||
/// Create a new `AuthRpcModule` with the given `engine_api`.
|
||||
pub fn new<EngineApi>(engine: EngineApi) -> Self
|
||||
pub fn new<EngineApi, EngineT>(engine: EngineApi) -> Self
|
||||
where
|
||||
EngineApi: EngineApiServer,
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
{
|
||||
let mut module = RpcModule::new(());
|
||||
module.merge(engine.into_rpc()).expect("No conflicting methods");
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use reth_network_api::{NetworkInfo, Peers};
|
||||
//! use reth_node_api::EngineTypes;
|
||||
//! use reth_provider::{
|
||||
//! AccountReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider,
|
||||
//! ChangeSetReader, EvmEnvProvider, StateProviderFactory,
|
||||
@@ -82,7 +83,7 @@
|
||||
//! use reth_tasks::TokioTaskExecutor;
|
||||
//! use reth_transaction_pool::TransactionPool;
|
||||
//! use tokio::try_join;
|
||||
//! pub async fn launch<Provider, Pool, Network, Events, EngineApi>(
|
||||
//! pub async fn launch<Provider, Pool, Network, Events, EngineApi, EngineT>(
|
||||
//! provider: Provider,
|
||||
//! pool: Pool,
|
||||
//! network: Network,
|
||||
@@ -101,7 +102,8 @@
|
||||
//! Pool: TransactionPool + Clone + 'static,
|
||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||
//! Events: CanonStateSubscriptions + Clone + 'static,
|
||||
//! EngineApi: EngineApiServer,
|
||||
//! EngineApi: EngineApiServer<EngineT>,
|
||||
//! EngineT: EngineTypes,
|
||||
//! {
|
||||
//! // configure the rpc module per transport
|
||||
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
||||
@@ -148,6 +150,7 @@ use jsonrpsee::{
|
||||
server::{IdProvider, Server, ServerHandle},
|
||||
Methods, RpcModule,
|
||||
};
|
||||
use reth_node_api::EngineTypes;
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use strum::{AsRefStr, EnumIter, EnumVariantNames, IntoStaticStr, ParseError, VariantNames};
|
||||
use tower::layer::util::{Identity, Stack};
|
||||
@@ -379,7 +382,7 @@ where
|
||||
///
|
||||
/// This behaves exactly as [RpcModuleBuilder::build] for the [TransportRpcModules], but also
|
||||
/// configures the auth (engine api) server, which exposes a subset of the `eth_` namespace.
|
||||
pub fn build_with_auth_server<EngineApi>(
|
||||
pub fn build_with_auth_server<EngineApi, EngineT: EngineTypes>(
|
||||
self,
|
||||
module_config: TransportRpcModuleConfig,
|
||||
engine: EngineApi,
|
||||
@@ -389,7 +392,7 @@ where
|
||||
RethModuleRegistry<Provider, Pool, Network, Tasks, Events>,
|
||||
)
|
||||
where
|
||||
EngineApi: EngineApiServer,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
{
|
||||
let mut modules = TransportRpcModules::default();
|
||||
|
||||
@@ -1020,9 +1023,10 @@ where
|
||||
/// * `api_` namespace
|
||||
///
|
||||
/// Note: This does _not_ register the `engine_` in this registry.
|
||||
pub fn create_auth_module<EngineApi>(&mut self, engine_api: EngineApi) -> AuthRpcModule
|
||||
pub fn create_auth_module<EngineApi, EngineT>(&mut self, engine_api: EngineApi) -> AuthRpcModule
|
||||
where
|
||||
EngineApi: EngineApiServer,
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
{
|
||||
let eth_handlers = self.eth_handlers();
|
||||
let mut module = RpcModule::new(());
|
||||
|
||||
Reference in New Issue
Block a user