converted EngineTypes to PayloadTypes (#15148)

This commit is contained in:
Ishika Choudhury
2025-03-19 18:35:34 +05:30
committed by GitHub
parent 01e5492134
commit 18056cf9a4
3 changed files with 17 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ use std::task::{Context, Poll};
use reth_engine_primitives::EngineTypes;
use reth_network::import::BlockImportError;
use reth_network_api::PeerId;
use reth_payload_primitives::PayloadTypes;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use super::service::{BlockMsg, IncomingBlock, Outcome};
@@ -13,14 +14,14 @@ use super::service::{BlockMsg, IncomingBlock, Outcome};
/// [`super::service::ImportService`]:
/// - Blocks can be sent to the service for import via [`send_block`](ImportHandle::send_block)
/// - Import outcomes can be received via [`poll_outcome`](ImportHandle::poll_outcome)`
pub struct ImportHandle<T: EngineTypes> {
pub struct ImportHandle<T: PayloadTypes> {
/// Send the new block to the service
to_import: UnboundedSender<IncomingBlock<T>>,
/// Receive the outcome of the import
import_outcome: UnboundedReceiver<Outcome<T>>,
}
impl<T: EngineTypes> ImportHandle<T> {
impl<T: PayloadTypes> ImportHandle<T> {
/// Create a new handle with the provided channels
pub fn new(
to_import: UnboundedSender<IncomingBlock<T>>,

View File

@@ -3,7 +3,7 @@ use handle::ImportHandle;
use reth_engine_primitives::EngineTypes;
use reth_network::import::BlockImport;
use reth_network_peers::PeerId;
use reth_payload_primitives::BuiltPayload;
use reth_payload_primitives::{BuiltPayload, PayloadTypes};
use reth_primitives::NodePrimitives;
use service::{BlockMsg, Outcome};
use std::{
@@ -15,25 +15,25 @@ mod handle;
mod parlia;
mod service;
pub struct BscBlockImport<EngineT: EngineTypes> {
handle: ImportHandle<EngineT>,
pub struct BscBlockImport<T: PayloadTypes> {
handle: ImportHandle<T>,
}
impl<EngineT: EngineTypes> BscBlockImport<EngineT> {
pub fn new(handle: ImportHandle<EngineT>) -> Self {
impl<T: PayloadTypes> BscBlockImport<T> {
pub fn new(handle: ImportHandle<T>) -> Self {
Self { handle }
}
}
impl<EngineT: EngineTypes>
BlockImport<<<EngineT::BuiltPayload as BuiltPayload>::Primitives as NodePrimitives>::Block>
for BscBlockImport<EngineT>
impl<T: PayloadTypes>
BlockImport<<<T::BuiltPayload as BuiltPayload>::Primitives as NodePrimitives>::Block>
for BscBlockImport<T>
{
fn on_new_block(&mut self, peer_id: PeerId, incoming_block: BlockMsg<EngineT>) {
fn on_new_block(&mut self, peer_id: PeerId, incoming_block: BlockMsg<T>) {
let _ = self.handle.send_block(incoming_block, peer_id);
}
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Outcome<EngineT>> {
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Outcome<T>> {
match ready!(self.handle.poll_outcome(cx)) {
Some(outcome) => Poll::Ready(outcome),
None => Poll::Pending,
@@ -41,7 +41,7 @@ impl<EngineT: EngineTypes>
}
}
impl<EngineT: EngineTypes> fmt::Debug for BscBlockImport<EngineT> {
impl<T: PayloadTypes> fmt::Debug for BscBlockImport<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BscBlockImport")
.field("engine_handle", &"BeaconConsensusEngineHandle")

View File

@@ -45,7 +45,7 @@ pub(crate) type IncomingBlock<T> = (BlockMsg<T>, PeerId);
pub struct ImportService<Provider, T>
where
Provider: BlockNumReader + Clone,
T: EngineTypes,
T: PayloadTypes,
{
/// The handle to communicate with the engine service
engine: BeaconConsensusEngineHandle<T>,
@@ -62,7 +62,7 @@ where
impl<Provider, T> ImportService<Provider, T>
where
Provider: BlockNumReader + Clone + 'static,
T: EngineTypes,
T: PayloadTypes,
{
/// Create a new block import service
pub fn new(
@@ -195,7 +195,7 @@ where
impl<Provider, T> Future for ImportService<Provider, T>
where
Provider: BlockNumReader + BlockHashReader + Clone + 'static + Unpin,
T: EngineTypes,
T: PayloadTypes,
{
type Output = Result<(), Box<dyn std::error::Error>>;