diff --git a/crates/engine/tree/src/engine.rs b/crates/engine/tree/src/engine.rs index e5314029f5..c7cbbb9f5a 100644 --- a/crates/engine/tree/src/engine.rs +++ b/crates/engine/tree/src/engine.rs @@ -6,8 +6,7 @@ use crate::{ download::{BlockDownloader, DownloadAction, DownloadOutcome}, }; use futures::{Stream, StreamExt}; -use reth_beacon_consensus::{BeaconConsensusEngineEvent, BeaconEngineMessage}; -use reth_engine_primitives::EngineTypes; +use reth_beacon_consensus::BeaconConsensusEngineEvent; use reth_primitives::{SealedBlockWithSenders, B256}; use std::{ collections::HashSet, @@ -54,12 +53,18 @@ impl EngineHandler { { Self { handler, incoming_requests, downloader } } + + /// Returns a mutable reference to the request handler. + pub fn handler_mut(&mut self) -> &mut T { + &mut self.handler + } } impl ChainHandler for EngineHandler where T: EngineRequestHandler, - S: Stream + Send + Sync + Unpin + 'static, + S: Stream + Send + Sync + Unpin + 'static, + ::Item: Into, D: BlockDownloader, { type Event = T::Event; @@ -98,7 +103,7 @@ where // pop the next incoming request if let Poll::Ready(Some(req)) = self.incoming_requests.poll_next_unpin(cx) { // and delegate the request to the handler - self.handler.on_event(FromEngine::Request(req)); + self.handler.on_event(FromEngine::Request(req.into())); // skip downloading in this iteration to allow the handler to process the request continue } @@ -156,32 +161,29 @@ pub trait EngineRequestHandler: Send + Sync { /// In case required blocks are missing, the handler will request them from the network, by emitting /// a download request upstream. #[derive(Debug)] -pub struct EngineApiRequestHandler { +pub struct EngineApiRequestHandler { /// channel to send messages to the tree to execute the payload. - to_tree: Sender>>, + to_tree: Sender>, /// channel to receive messages from the tree. from_tree: UnboundedReceiver, } -impl EngineApiRequestHandler -where - T: EngineTypes, -{ +impl EngineApiRequestHandler { /// Creates a new `EngineApiRequestHandler`. pub const fn new( - to_tree: Sender>>, + to_tree: Sender>, from_tree: UnboundedReceiver, ) -> Self { Self { to_tree, from_tree } } } -impl EngineRequestHandler for EngineApiRequestHandler +impl EngineRequestHandler for EngineApiRequestHandler where - T: EngineTypes, + Request: Send, { type Event = BeaconConsensusEngineEvent; - type Request = BeaconEngineMessage; + type Request = Request; fn on_event(&mut self, event: FromEngine) { // delegate to the tree diff --git a/crates/ethereum/engine/src/service.rs b/crates/ethereum/engine/src/service.rs index 9ec9fcf9cc..5a1c409fd1 100644 --- a/crates/ethereum/engine/src/service.rs +++ b/crates/ethereum/engine/src/service.rs @@ -33,7 +33,7 @@ use tokio_stream::wrappers::UnboundedReceiverStream; /// Alias for Ethereum chain orchestrator. type EthServiceType = ChainOrchestrator< EngineHandler< - EngineApiRequestHandler, + EngineApiRequestHandler>, UnboundedReceiverStream>, BasicBlockDownloader, >,