chore: expose blob_versioned_hashes methods on block (#8530)

This commit is contained in:
Dan Cline
2024-05-31 12:46:46 -04:00
committed by GitHub
parent b8e8ce1f40
commit ce9154d9bd

View File

@ -144,6 +144,32 @@ impl Block {
self.body.iter().any(|tx| tx.is_eip4844()) self.body.iter().any(|tx| tx.is_eip4844())
} }
/// Returns an iterator over all blob transactions of the block
#[inline]
pub fn blob_transactions_iter(&self) -> impl Iterator<Item = &TransactionSigned> + '_ {
self.body.iter().filter(|tx| tx.is_eip4844())
}
/// Returns only the blob transactions, if any, from the block body.
#[inline]
pub fn blob_transactions(&self) -> Vec<&TransactionSigned> {
self.blob_transactions_iter().collect()
}
/// Returns an iterator over all blob versioned hashes from the block body.
#[inline]
pub fn blob_versioned_hashes_iter(&self) -> impl Iterator<Item = &B256> + '_ {
self.blob_transactions_iter()
.filter_map(|tx| tx.as_eip4844().map(|blob_tx| &blob_tx.blob_versioned_hashes))
.flatten()
}
/// Returns all blob versioned hashes from the block body.
#[inline]
pub fn blob_versioned_hashes(&self) -> Vec<&B256> {
self.blob_versioned_hashes_iter().collect()
}
/// Calculates a heuristic for the in-memory size of the [Block]. /// Calculates a heuristic for the in-memory size of the [Block].
#[inline] #[inline]
pub fn size(&self) -> usize { pub fn size(&self) -> usize {