diff --git a/crates/rpc/rpc-convert/src/transaction.rs b/crates/rpc/rpc-convert/src/transaction.rs index 613800e3dd4..856a02c2896 100644 --- a/crates/rpc/rpc-convert/src/transaction.rs +++ b/crates/rpc/rpc-convert/src/transaction.rs @@ -14,7 +14,7 @@ use reth_primitives_traits::{ BlockTy, HeaderTy, NodePrimitives, SealedBlock, SealedHeader, SealedHeaderFor, TransactionMeta, TxTy, }; -use std::{convert::Infallible, error::Error, fmt::Debug, marker::PhantomData}; +use std::{convert::Infallible, error::Error, fmt, fmt::Debug, marker::PhantomData}; /// Input for [`RpcConvert::convert_receipts`]. #[derive(Debug, Clone)] @@ -58,7 +58,7 @@ pub trait ReceiptConverter: Debug + 'static { } /// A type that knows how to convert a consensus header into an RPC header. -pub trait HeaderConverter: Debug + Send + Sync + Unpin + Clone + 'static { +pub trait HeaderConverter: Send + Sync + Unpin + Clone + 'static { /// An associated RPC conversion error. type Err: error::Error; @@ -87,6 +87,21 @@ where } } +impl HeaderConverter for F +where + F: Fn(SealedHeader, usize) -> Rpc + Send + Sync + Unpin + Clone + 'static, +{ + type Err = Infallible; + + fn convert_header( + &self, + header: SealedHeader, + block_size: usize, + ) -> Result { + Ok(self(header, block_size)) + } +} + /// Conversion trait for obtaining RPC header from a consensus header. pub trait FromConsensusHeader { /// Takes a consensus header and converts it into `self`. @@ -280,7 +295,7 @@ where /// One should prefer to implement [`IntoRpcTx`] for `Tx` to get the `RpcTxConverter` implementation /// for free, thanks to the blanket implementation, unless the conversion requires more context. For /// example, some configuration parameters or access handles to database, network, etc. -pub trait RpcTxConverter: Clone + Debug + Unpin + Send + Sync + 'static { +pub trait RpcTxConverter: Clone + Unpin + Send + Sync + 'static { /// An associated error that can happen during the conversion. type Err; @@ -308,7 +323,7 @@ where impl RpcTxConverter for F where - F: Fn(Tx, Address, TxInfo) -> Result + Clone + Debug + Unpin + Send + Sync + 'static, + F: Fn(Tx, Address, TxInfo) -> Result + Clone + Unpin + Send + Sync + 'static, { type Err = E; @@ -332,7 +347,7 @@ where /// implementation for free, thanks to the blanket implementation, unless the conversion requires /// more context. For example, some configuration parameters or access handles to database, network, /// etc. -pub trait SimTxConverter: Clone + Debug + Unpin + Send + Sync + 'static { +pub trait SimTxConverter: Clone + Unpin + Send + Sync + 'static { /// An associated error that can occur during the conversion. type Err: Error; @@ -357,7 +372,7 @@ impl SimTxConverter for F where TxReq: Debug, E: Error, - F: Fn(TxReq) -> Result + Clone + Debug + Unpin + Send + Sync + 'static, + F: Fn(TxReq) -> Result + Clone + Unpin + Send + Sync + 'static, { type Err = E; @@ -507,7 +522,6 @@ pub enum TransactionConversionError { /// implemented for a dedicated struct that is assigned to `Map`. If [`FromConsensusTx::TxInfo`] /// is [`TransactionInfo`] then `()` can be used as `Map` which trivially passes over the input /// object. -#[derive(Debug)] pub struct RpcConverter< Network, Evm, @@ -528,6 +542,14 @@ pub struct RpcConverter< rpc_tx_converter: RpcTx, } +impl fmt::Debug + for RpcConverter +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RpcConverter").finish_non_exhaustive() + } +} + impl RpcConverter { /// Creates a new [`RpcConverter`] with `receipt_converter` and `mapper`. pub const fn new(receipt_converter: Receipt) -> Self {