diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index 780551891621..aa12adaacffd 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -200,8 +200,7 @@ impl RpcServerArgs { .with_events(components.events()) .with_executor(components.task_executor()) .build_with_auth_server(module_config, engine_api); - let node_modules = - &mut RethRpcComponents:: { registry: &mut registry, modules: &mut modules }; + let node_modules = RethRpcComponents { registry: &mut registry, modules: &mut modules }; // apply configured customization conf.extend_rpc_modules(self, components, node_modules)?; diff --git a/bin/reth/src/cli/components.rs b/bin/reth/src/cli/components.rs index d047e4da5468..1f51409cbce7 100644 --- a/bin/reth/src/cli/components.rs +++ b/bin/reth/src/cli/components.rs @@ -72,11 +72,17 @@ pub trait RethNodeComponents { } } -/// Helper function to encapsulate [RethModuleRegistry] and [TransportRpcModules] -/// generic over [RethNodeComponents] +/// Helper container to encapsulate [RethModuleRegistry] and [TransportRpcModules]. +/// +/// This can be used to access installed modules, or create commonly used handlers like +/// [reth_rpc::EthApi], and ultimately merge additional rpc handler into the configured transport +/// modules [TransportRpcModules]. +#[derive(Debug)] #[allow(clippy::type_complexity)] pub struct RethRpcComponents<'a, Reth: RethNodeComponents> { /// A Helper type the holds instances of the configured modules. + /// + /// This provides easy access to rpc handlers, such as [RethModuleRegistry::eth_api]. pub registry: &'a mut RethModuleRegistry< Reth::Provider, Reth::Pool, @@ -85,6 +91,9 @@ pub struct RethRpcComponents<'a, Reth: RethNodeComponents> { Reth::Events, >, /// Holds installed modules per transport type. + /// + /// This can be used to merge additional modules into the configured transports (http, ipc, + /// ws). See [TransportRpcModules::merge_configured] pub modules: &'a mut TransportRpcModules, } diff --git a/bin/reth/src/cli/ext.rs b/bin/reth/src/cli/ext.rs index 857ec4811dc5..c61ef3a9a181 100644 --- a/bin/reth/src/cli/ext.rs +++ b/bin/reth/src/cli/ext.rs @@ -50,12 +50,11 @@ pub trait RethNodeCommandConfig: fmt::Debug { /// /// This is expected to call the merge functions of [reth_rpc_builder::TransportRpcModules], for /// example [reth_rpc_builder::TransportRpcModules::merge_configured] - #[allow(clippy::type_complexity)] fn extend_rpc_modules( &mut self, config: &Conf, components: &Reth, - rpc_components: &mut RethRpcComponents<'_, Reth>, + rpc_components: RethRpcComponents<'_, Reth>, ) -> eyre::Result<()> where Conf: RethRpcConfig, @@ -187,14 +186,14 @@ impl RethNodeCommandConfig for NoArgs { &mut self, config: &Conf, components: &Reth, - node_components: &mut RethRpcComponents<'_, Reth>, + rpc_components: RethRpcComponents<'_, Reth>, ) -> eyre::Result<()> where Conf: RethRpcConfig, Reth: RethNodeComponents, { if let Some(conf) = self.inner_mut() { - conf.extend_rpc_modules(config, components, node_components) + conf.extend_rpc_modules(config, components, rpc_components) } else { Ok(()) } diff --git a/examples/additional-rpc-namespace-in-cli/src/main.rs b/examples/additional-rpc-namespace-in-cli/src/main.rs index d2315f2015a2..ce03aa5c8e3e 100644 --- a/examples/additional-rpc-namespace-in-cli/src/main.rs +++ b/examples/additional-rpc-namespace-in-cli/src/main.rs @@ -47,7 +47,7 @@ impl RethNodeCommandConfig for RethCliTxpoolExt { &mut self, _config: &Conf, _components: &Reth, - node_components: &mut RethRpcComponents<'_, Reth>, + rpc_components: RethRpcComponents<'_, Reth>, ) -> eyre::Result<()> where Conf: RethRpcConfig, @@ -58,11 +58,11 @@ impl RethNodeCommandConfig for RethCliTxpoolExt { } // here we get the configured pool type from the CLI. - let pool = node_components.registry.pool().clone(); + let pool = rpc_components.registry.pool().clone(); let ext = TxpoolExt { pool }; // now we merge our extension namespace into all configured transports - node_components.modules.merge_configured(ext.into_rpc())?; + rpc_components.modules.merge_configured(ext.into_rpc())?; println!("txpool extension enabled"); Ok(())