mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(rpc): EthApi builder (#9041)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -308,7 +308,7 @@ where
|
||||
let jwt_secret = ctx.auth_jwt_secret()?;
|
||||
|
||||
// Start RPC servers
|
||||
let (rpc_server_handles, mut rpc_registry) = crate::rpc::launch_rpc_servers(
|
||||
let (rpc_server_handles, rpc_registry) = crate::rpc::launch_rpc_servers(
|
||||
ctx.node_adapter().clone(),
|
||||
engine_api,
|
||||
ctx.node_config(),
|
||||
|
||||
@ -1,22 +1,24 @@
|
||||
//! Builder support for rpc components.
|
||||
|
||||
use std::{
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
use futures::TryFutureExt;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_node_core::{node_config::NodeConfig, rpc::api::EngineApiServer};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_rpc::eth::EthApi;
|
||||
use reth_rpc_builder::{
|
||||
auth::{AuthRpcModule, AuthServerHandle},
|
||||
config::RethRpcServerConfig,
|
||||
RethModuleRegistry, RpcModuleBuilder, RpcServerHandle, TransportRpcModules,
|
||||
EthApiBuild, RpcModuleBuilder, RpcRegistryInner, RpcServerHandle, TransportRpcModules,
|
||||
};
|
||||
use reth_rpc_layer::JwtSecret;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use std::{
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
/// Contains the handles to the spawned RPC servers.
|
||||
///
|
||||
@ -145,27 +147,28 @@ impl<Node: FullNodeComponents> ExtendRpcModules<Node> for () {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper wrapper type to encapsulate the [`RethModuleRegistry`] over components trait.
|
||||
/// Helper wrapper type to encapsulate the [`RpcRegistryInner`] over components trait.
|
||||
#[derive(Debug)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub struct RpcRegistry<Node: FullNodeComponents> {
|
||||
pub(crate) registry: RethModuleRegistry<
|
||||
pub(crate) registry: RpcRegistryInner<
|
||||
Node::Provider,
|
||||
Node::Pool,
|
||||
NetworkHandle,
|
||||
TaskExecutor,
|
||||
Node::Provider,
|
||||
Node::Evm,
|
||||
EthApi<Node::Provider, Node::Pool, NetworkHandle, Node::Evm>,
|
||||
>,
|
||||
}
|
||||
|
||||
impl<Node: FullNodeComponents> Deref for RpcRegistry<Node> {
|
||||
type Target = RethModuleRegistry<
|
||||
type Target = RpcRegistryInner<
|
||||
Node::Provider,
|
||||
Node::Pool,
|
||||
NetworkHandle,
|
||||
TaskExecutor,
|
||||
Node::Provider,
|
||||
Node::Evm,
|
||||
EthApi<Node::Provider, Node::Pool, NetworkHandle, Node::Evm>,
|
||||
>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@ -185,7 +188,7 @@ impl<Node: FullNodeComponents> Clone for RpcRegistry<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper container to encapsulate [`RethModuleRegistry`], [`TransportRpcModules`] and
|
||||
/// Helper container to encapsulate [`RpcRegistryInner`], [`TransportRpcModules`] and
|
||||
/// [`AuthRpcModule`].
|
||||
///
|
||||
/// This can be used to access installed modules, or create commonly used handlers like
|
||||
@ -202,7 +205,7 @@ pub struct RpcContext<'a, Node: FullNodeComponents> {
|
||||
|
||||
/// A Helper type the holds instances of the configured modules.
|
||||
///
|
||||
/// This provides easy access to rpc handlers, such as [`RethModuleRegistry::eth_api`].
|
||||
/// This provides easy access to rpc handlers, such as [`RpcRegistryInner::eth_api`].
|
||||
pub registry: &'a mut RpcRegistry<Node>,
|
||||
/// Holds installed modules per transport type.
|
||||
///
|
||||
@ -272,7 +275,7 @@ where
|
||||
.with_events(node.provider().clone())
|
||||
.with_executor(node.task_executor().clone())
|
||||
.with_evm_config(node.evm_config().clone())
|
||||
.build_with_auth_server(module_config, engine_api);
|
||||
.build_with_auth_server(module_config, engine_api, EthApiBuild::build);
|
||||
|
||||
let mut registry = RpcRegistry { registry };
|
||||
let ctx = RpcContext {
|
||||
|
||||
Reference in New Issue
Block a user