mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(rpc): LoadReceipt::build_transaction_receipt default impl to impl for EthApi (#10786)
This commit is contained in:
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
|
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
|
||||||
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
|
use reth_rpc_eth_types::EthStateCache;
|
||||||
use reth_rpc_types::AnyTransactionReceipt;
|
use reth_rpc_types::AnyTransactionReceipt;
|
||||||
|
|
||||||
use crate::{EthApiTypes, FromEthApiError};
|
use crate::EthApiTypes;
|
||||||
|
|
||||||
/// Assembles transaction receipt data w.r.t to network.
|
/// Assembles transaction receipt data w.r.t to network.
|
||||||
///
|
///
|
||||||
@ -23,18 +23,5 @@ pub trait LoadReceipt: EthApiTypes + Send + Sync {
|
|||||||
tx: TransactionSigned,
|
tx: TransactionSigned,
|
||||||
meta: TransactionMeta,
|
meta: TransactionMeta,
|
||||||
receipt: Receipt,
|
receipt: Receipt,
|
||||||
) -> impl Future<Output = Result<AnyTransactionReceipt, Self::Error>> + Send {
|
) -> impl Future<Output = Result<AnyTransactionReceipt, Self::Error>> + Send;
|
||||||
async move {
|
|
||||||
let hash = meta.block_hash;
|
|
||||||
// get all receipts for the block
|
|
||||||
let all_receipts = self
|
|
||||||
.cache()
|
|
||||||
.get_receipts(hash)
|
|
||||||
.await
|
|
||||||
.map_err(Self::Error::from_eth_err)?
|
|
||||||
.ok_or(EthApiError::HeaderNotFound(hash.into()))?;
|
|
||||||
|
|
||||||
Ok(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
//! Builds an RPC receipt response w.r.t. data layout of network.
|
//! Builds an RPC receipt response w.r.t. data layout of network.
|
||||||
|
|
||||||
use reth_rpc_eth_api::helpers::LoadReceipt;
|
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
|
||||||
use reth_rpc_eth_types::EthStateCache;
|
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError};
|
||||||
|
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
|
||||||
|
use reth_rpc_types::AnyTransactionReceipt;
|
||||||
|
|
||||||
use crate::EthApi;
|
use crate::EthApi;
|
||||||
|
|
||||||
@ -13,4 +15,22 @@ where
|
|||||||
fn cache(&self) -> &EthStateCache {
|
fn cache(&self) -> &EthStateCache {
|
||||||
self.inner.cache()
|
self.inner.cache()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn build_transaction_receipt(
|
||||||
|
&self,
|
||||||
|
tx: TransactionSigned,
|
||||||
|
meta: TransactionMeta,
|
||||||
|
receipt: Receipt,
|
||||||
|
) -> Result<AnyTransactionReceipt, Self::Error> {
|
||||||
|
let hash = meta.block_hash;
|
||||||
|
// get all receipts for the block
|
||||||
|
let all_receipts = self
|
||||||
|
.cache()
|
||||||
|
.get_receipts(hash)
|
||||||
|
.await
|
||||||
|
.map_err(Self::Error::from_eth_err)?
|
||||||
|
.ok_or(EthApiError::HeaderNotFound(hash.into()))?;
|
||||||
|
|
||||||
|
Ok(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user