chore(rpc): add super trait RpcNodeCoreExt to LoadReceipt (#12149)

This commit is contained in:
Emilia Hane
2024-10-29 02:09:58 +08:00
committed by GitHub
parent 473026f40a
commit 3d62bfde14
4 changed files with 10 additions and 24 deletions

View File

@ -145,7 +145,8 @@ pub trait EthBlocks: LoadBlock {
if let Some(block_hash) =
self.provider().block_hash_for_id(block_id).map_err(Self::Error::from_eth_err)?
{
return LoadReceipt::cache(self)
return self
.cache()
.get_block_and_receipts(block_hash)
.await
.map_err(Self::Error::from_eth_err)

View File

@ -3,19 +3,13 @@
use futures::Future;
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use reth_rpc_eth_types::EthStateCache;
use crate::{EthApiTypes, RpcReceipt};
use crate::{EthApiTypes, RpcNodeCoreExt, RpcReceipt};
/// Assembles transaction receipt data w.r.t to network.
///
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` receipts RPC methods.
pub trait LoadReceipt: EthApiTypes + Send + Sync {
/// Returns a handle for reading data from memory.
///
/// Data access in default (L1) trait method implementations.
fn cache(&self) -> &EthStateCache;
pub trait LoadReceipt: EthApiTypes + RpcNodeCoreExt + Send + Sync {
/// Helper method for `eth_getBlockReceipts` and `eth_getTransactionReceipt`.
fn build_transaction_receipt(
&self,

View File

@ -2,20 +2,15 @@
use alloy_serde::WithOtherFields;
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcReceipt};
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcNodeCoreExt, RpcReceipt};
use reth_rpc_eth_types::{EthApiError, ReceiptBuilder};
use crate::EthApi;
impl<Provider, Pool, Network, EvmConfig> LoadReceipt for EthApi<Provider, Pool, Network, EvmConfig>
where
Self: Send + Sync,
Self: RpcNodeCoreExt,
{
#[inline]
fn cache(&self) -> &EthStateCache {
self.inner.cache()
}
async fn build_transaction_receipt(
&self,
tx: TransactionSigned,