reth_rpc_eth_types/
block.rs1use std::sync::Arc;
4
5use alloy_primitives::TxHash;
6use reth_primitives_traits::{
7 BlockTy, IndexedTx, NodePrimitives, ReceiptTy, RecoveredBlock, SealedBlock,
8};
9
10#[derive(Debug, Clone)]
15pub struct BlockAndReceipts<N: NodePrimitives> {
16 pub block: Arc<RecoveredBlock<BlockTy<N>>>,
18 pub receipts: Arc<Vec<ReceiptTy<N>>>,
20}
21
22impl<N: NodePrimitives> BlockAndReceipts<N> {
23 pub const fn new(
25 block: Arc<RecoveredBlock<BlockTy<N>>>,
26 receipts: Arc<Vec<ReceiptTy<N>>>,
27 ) -> Self {
28 Self { block, receipts }
29 }
30
31 pub fn find_transaction_and_receipt_by_hash(
35 &self,
36 tx_hash: TxHash,
37 ) -> Option<(IndexedTx<'_, N::Block>, &N::Receipt)> {
38 let indexed_tx = self.block.find_indexed(tx_hash)?;
39 let receipt = self.receipts.get(indexed_tx.index())?;
40 Some((indexed_tx, receipt))
41 }
42
43 pub fn sealed_block(&self) -> &SealedBlock<BlockTy<N>> {
45 self.block.sealed_block()
46 }
47}