chore: replace RichBlock by Block (#10399)

Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
This commit is contained in:
Miguel Tavares
2024-08-22 00:08:07 -03:00
committed by GitHub
parent 5644347583
commit dc4643f69c
2 changed files with 9 additions and 13 deletions

View File

@ -15,8 +15,8 @@ use reth_rpc_types::{
serde_helpers::JsonStorageKey,
simulate::{SimBlock, SimulatedBlock},
state::{EvmOverrides, StateOverride},
AnyTransactionReceipt, BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse,
FeeHistory, Header, Index, RichBlock, StateContext, SyncStatus, Transaction,
AnyTransactionReceipt, Block, BlockOverrides, Bundle, EIP1186AccountProofResponse,
EthCallResponse, FeeHistory, Header, Index, RichBlock, StateContext, SyncStatus, Transaction,
TransactionRequest, Work,
};
use tracing::trace;
@ -102,7 +102,7 @@ pub trait EthApi {
&self,
hash: B256,
index: Index,
) -> RpcResult<Option<RichBlock>>;
) -> RpcResult<Option<Block>>;
/// Returns an uncle block of the given block and index.
#[method(name = "getUncleByBlockNumberAndIndex")]
@ -110,7 +110,7 @@ pub trait EthApi {
&self,
number: BlockNumberOrTag,
index: Index,
) -> RpcResult<Option<RichBlock>>;
) -> RpcResult<Option<Block>>;
/// Returns the EIP-2718 encoded transaction if it exists.
///
@ -449,7 +449,7 @@ where
&self,
hash: B256,
index: Index,
) -> RpcResult<Option<RichBlock>> {
) -> RpcResult<Option<Block>> {
trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getUncleByBlockHashAndIndex");
Ok(EthBlocks::ommer_by_block_and_index(self, hash.into(), index).await?)
}
@ -459,7 +459,7 @@ where
&self,
number: BlockNumberOrTag,
index: Index,
) -> RpcResult<Option<RichBlock>> {
) -> RpcResult<Option<Block>> {
trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getUncleByBlockNumberAndIndex");
Ok(EthBlocks::ommer_by_block_and_index(self, number.into(), index).await?)
}

View File

@ -6,7 +6,7 @@ use futures::Future;
use reth_primitives::{BlockId, Receipt, SealedBlock, SealedBlockWithSenders, TransactionMeta};
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, HeaderProvider};
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
use reth_rpc_types::{AnyTransactionReceipt, Header, Index, RichBlock};
use reth_rpc_types::{AnyTransactionReceipt, Block, Header, Index, RichBlock};
use reth_rpc_types_compat::block::{from_block, uncle_block_from_header};
use crate::FromEthApiError;
@ -187,7 +187,7 @@ pub trait EthBlocks: LoadBlock {
&self,
block_id: BlockId,
index: Index,
) -> impl Future<Output = Result<Option<RichBlock>, Self::Error>> + Send {
) -> impl Future<Output = Result<Option<Block>, Self::Error>> + Send {
async move {
let uncles = if block_id.is_pending() {
// Pending block can be fetched directly without need for caching
@ -202,11 +202,7 @@ pub trait EthBlocks: LoadBlock {
}
.unwrap_or_default();
let uncle = uncles
.into_iter()
.nth(index.into())
.map(|header| uncle_block_from_header(header).into());
Ok(uncle)
Ok(uncles.into_iter().nth(index.into()).map(uncle_block_from_header))
}
}
}