mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
added EventSender to FullNode type (#14268)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -198,6 +198,7 @@ where
|
||||
info!(target: "reth::cli", prune_config=?ctx.prune_config().unwrap_or_default(), "Pruner initialized");
|
||||
|
||||
let event_sender = EventSender::default();
|
||||
|
||||
let beacon_engine_handle = BeaconConsensusEngineHandle::new(consensus_engine_tx.clone());
|
||||
|
||||
// extract the jwt secret from the args if possible
|
||||
@ -208,6 +209,7 @@ where
|
||||
config: ctx.node_config(),
|
||||
beacon_engine_handle: beacon_engine_handle.clone(),
|
||||
jwt_secret,
|
||||
engine_events: event_sender.clone(),
|
||||
};
|
||||
let engine_payload_validator = add_ons.engine_validator(&add_ons_ctx).await?;
|
||||
|
||||
@ -270,6 +272,7 @@ where
|
||||
pruner_events.map(Into::into),
|
||||
static_file_producer_events.map(Into::into),
|
||||
);
|
||||
|
||||
ctx.task_executor().spawn_critical(
|
||||
"events task",
|
||||
node::handle_events(
|
||||
@ -279,7 +282,7 @@ where
|
||||
),
|
||||
);
|
||||
|
||||
let RpcHandle { rpc_server_handles, rpc_registry } =
|
||||
let RpcHandle { rpc_server_handles, rpc_registry, engine_events } =
|
||||
add_ons.launch_add_ons(add_ons_ctx).await?;
|
||||
|
||||
// TODO: migrate to devmode with https://github.com/paradigmxyz/reth/issues/10104
|
||||
@ -403,7 +406,7 @@ where
|
||||
task_executor: ctx.task_executor().clone(),
|
||||
config: ctx.node_config().clone(),
|
||||
data_dir: ctx.data_dir().clone(),
|
||||
add_ons_handle: RpcHandle { rpc_server_handles, rpc_registry },
|
||||
add_ons_handle: RpcHandle { rpc_server_handles, rpc_registry, engine_events },
|
||||
};
|
||||
// Notify on node started
|
||||
on_node_started.on_event(FullNode::clone(&full_node))?;
|
||||
|
||||
@ -7,6 +7,7 @@ use std::{
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
use crate::{BeaconConsensusEngineEvent, EthApiBuilderCtx};
|
||||
use alloy_rpc_types::engine::ClientVersionV1;
|
||||
use futures::TryFutureExt;
|
||||
use reth_node_api::{
|
||||
@ -32,11 +33,10 @@ use reth_rpc_builder::{
|
||||
};
|
||||
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tokio_util::EventSender;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::EthApiBuilderCtx;
|
||||
|
||||
/// Contains the handles to the spawned RPC servers.
|
||||
///
|
||||
/// This can be used to access the endpoints of the servers.
|
||||
@ -301,12 +301,27 @@ where
|
||||
}
|
||||
|
||||
/// Handle to the launched RPC servers.
|
||||
#[derive(Clone)]
|
||||
pub struct RpcHandle<Node: FullNodeComponents, EthApi: EthApiTypes> {
|
||||
/// Handles to launched servers.
|
||||
pub rpc_server_handles: RethRpcServerHandles,
|
||||
/// Configured RPC modules.
|
||||
pub rpc_registry: RpcRegistry<Node, EthApi>,
|
||||
/// Notification channel for engine API events
|
||||
///
|
||||
/// Caution: This is a multi-producer, multi-consumer broadcast and allows grants access to
|
||||
/// dispatch events
|
||||
pub engine_events:
|
||||
EventSender<BeaconConsensusEngineEvent<<Node::Types as NodeTypes>::Primitives>>,
|
||||
}
|
||||
|
||||
impl<Node: FullNodeComponents, EthApi: EthApiTypes> Clone for RpcHandle<Node, EthApi> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
rpc_server_handles: self.rpc_server_handles.clone(),
|
||||
rpc_registry: self.rpc_registry.clone(),
|
||||
engine_events: self.engine_events.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Node: FullNodeComponents, EthApi: EthApiTypes> Deref for RpcHandle<Node, EthApi> {
|
||||
@ -424,7 +439,7 @@ where
|
||||
let Self { eth_api_builder, engine_validator_builder, hooks, _pd: _ } = self;
|
||||
|
||||
let engine_validator = engine_validator_builder.build(&ctx).await?;
|
||||
let AddOnsContext { node, config, beacon_engine_handle, jwt_secret } = ctx;
|
||||
let AddOnsContext { node, config, beacon_engine_handle, jwt_secret, engine_events } = ctx;
|
||||
|
||||
let client = ClientVersionV1 {
|
||||
code: CLIENT_CODE,
|
||||
@ -524,7 +539,7 @@ where
|
||||
|
||||
on_rpc_started.on_rpc_started(ctx, handles.clone())?;
|
||||
|
||||
Ok(RpcHandle { rpc_server_handles: handles, rpc_registry: registry })
|
||||
Ok(RpcHandle { rpc_server_handles: handles, rpc_registry: registry, engine_events })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user