Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/rpc/rpc-eth-types/src/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use reth_chain_state::{
};
use reth_ethereum_primitives::Receipt;
use reth_evm::EvmEnv;
use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock, SealedHeader};
use reth_primitives_traits::{Block, IndexedTx, NodePrimitives, RecoveredBlock, SealedHeader};

/// Configured [`EvmEnv`] for a pending block.
#[derive(Debug, Clone, Constructor)]
Expand Down Expand Up @@ -92,6 +92,20 @@ pub struct PendingBlockAndReceipts<N: NodePrimitives> {
pub receipts: PendingBlockReceipts<N>,
}

impl<N: NodePrimitives> PendingBlockAndReceipts<N> {
/// Finds a transaction by hash and returns it along with its corresponding receipt.
///
/// Returns `None` if the transaction is not found in this pending block.
pub fn find_transaction_and_receipt_by_hash(
&self,
tx_hash: alloy_primitives::TxHash,
) -> Option<(IndexedTx<'_, N::Block>, &N::Receipt)> {
let indexed_tx = self.block.find_indexed(tx_hash)?;
let receipt = self.receipts.get(indexed_tx.index())?;
Some((indexed_tx, receipt))
}
}

/// Locally built pending block for `pending` tag.
#[derive(Debug, Clone, Constructor)]
pub struct PendingBlock<N: NodePrimitives> {
Expand Down