mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
feat(execution-types): add receipts_iter and logs_iter helpers to Chain (#21240)
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
use crate::ExecutionOutcome;
|
||||
use alloc::{borrow::Cow, collections::BTreeMap, vec::Vec};
|
||||
use alloy_consensus::{transaction::Recovered, BlockHeader};
|
||||
use alloy_consensus::{transaction::Recovered, BlockHeader, TxReceipt};
|
||||
use alloy_eips::{eip1898::ForkBlock, eip2718::Encodable2718, BlockNumHash};
|
||||
use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash};
|
||||
use alloy_primitives::{Address, BlockHash, BlockNumber, Log, TxHash};
|
||||
use core::{fmt, ops::RangeInclusive};
|
||||
use reth_primitives_traits::{
|
||||
transaction::signed::SignedTransaction, Block, BlockBody, IndexedTx, NodePrimitives,
|
||||
@@ -184,6 +184,19 @@ impl<N: NodePrimitives> Chain<N> {
|
||||
self.execution_outcome.receipts().iter()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all receipts in the chain.
|
||||
pub fn receipts_iter(&self) -> impl Iterator<Item = &N::Receipt> + '_ {
|
||||
self.block_receipts_iter().flatten()
|
||||
}
|
||||
|
||||
/// Returns an iterator over all logs in the chain.
|
||||
pub fn logs_iter(&self) -> impl Iterator<Item = &Log> + '_
|
||||
where
|
||||
N::Receipt: TxReceipt<Log = Log>,
|
||||
{
|
||||
self.receipts_iter().flat_map(|receipt| receipt.logs())
|
||||
}
|
||||
|
||||
/// Returns an iterator over all blocks in the chain with increasing block number.
|
||||
pub fn blocks_iter(&self) -> impl Iterator<Item = &RecoveredBlock<N::Block>> + '_ {
|
||||
self.blocks().iter().map(|block| block.1)
|
||||
|
||||
Reference in New Issue
Block a user