mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc): integrate eth cache and task executor in pipeline (#1596)
This commit is contained in:
@ -11,6 +11,7 @@ use reth_rpc_builder::{
|
||||
RpcServerHandle, ServerBuilder, TransportRpcModuleConfig,
|
||||
};
|
||||
use reth_rpc_engine_api::EngineApiHandle;
|
||||
use reth_tasks::TaskSpawner;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
@ -103,11 +104,12 @@ impl RpcServerArgs {
|
||||
}
|
||||
|
||||
/// Convenience function for starting a rpc server with configs which extracted from cli args.
|
||||
pub(crate) async fn start_rpc_server<Client, Pool, Network>(
|
||||
pub(crate) async fn start_rpc_server<Client, Pool, Network, Tasks>(
|
||||
&self,
|
||||
client: Client,
|
||||
pool: Pool,
|
||||
network: Network,
|
||||
executor: Tasks,
|
||||
) -> Result<RpcServerHandle, RpcError>
|
||||
where
|
||||
Client: BlockProvider
|
||||
@ -115,9 +117,11 @@ impl RpcServerArgs {
|
||||
+ StateProviderFactory
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
{
|
||||
reth_rpc_builder::launch(
|
||||
client,
|
||||
@ -125,16 +129,18 @@ impl RpcServerArgs {
|
||||
network,
|
||||
self.transport_rpc_module_config(),
|
||||
self.rpc_server_config(),
|
||||
executor,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Create Engine API server.
|
||||
pub(crate) async fn start_auth_server<Client, Pool, Network>(
|
||||
pub(crate) async fn start_auth_server<Client, Pool, Network, Tasks>(
|
||||
&self,
|
||||
client: Client,
|
||||
pool: Pool,
|
||||
network: Network,
|
||||
executor: Tasks,
|
||||
handle: EngineApiHandle,
|
||||
) -> Result<ServerHandle, RpcError>
|
||||
where
|
||||
@ -143,16 +149,27 @@ impl RpcServerArgs {
|
||||
+ StateProviderFactory
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
+ 'static,
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
{
|
||||
let socket_address = SocketAddr::new(
|
||||
self.auth_addr.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
|
||||
self.auth_port.unwrap_or(constants::DEFAULT_AUTH_PORT),
|
||||
);
|
||||
let secret = self.jwt_secret().map_err(|err| RpcError::Custom(err.to_string()))?;
|
||||
reth_rpc_builder::auth::launch(client, pool, network, handle, socket_address, secret).await
|
||||
reth_rpc_builder::auth::launch(
|
||||
client,
|
||||
pool,
|
||||
network,
|
||||
executor,
|
||||
handle,
|
||||
socket_address,
|
||||
secret,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates the [TransportRpcModuleConfig] from cli args.
|
||||
|
||||
@ -160,7 +160,12 @@ impl Command {
|
||||
|
||||
let _rpc_server = self
|
||||
.rpc
|
||||
.start_rpc_server(shareable_db.clone(), test_transaction_pool.clone(), network.clone())
|
||||
.start_rpc_server(
|
||||
shareable_db.clone(),
|
||||
test_transaction_pool.clone(),
|
||||
network.clone(),
|
||||
ctx.task_executor.clone(),
|
||||
)
|
||||
.await?;
|
||||
info!(target: "reth::cli", "Started RPC server");
|
||||
|
||||
@ -174,6 +179,7 @@ impl Command {
|
||||
shareable_db,
|
||||
test_transaction_pool,
|
||||
network.clone(),
|
||||
ctx.task_executor.clone(),
|
||||
engine_api_handle,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user