mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add helper iter for tx hashes (#13638)
This commit is contained in:
@ -41,6 +41,11 @@ pub trait BlockBody:
|
||||
/// Returns reference to transactions in block.
|
||||
fn transactions(&self) -> &[Self::Transaction];
|
||||
|
||||
/// Returns an iterator over all transaction hashes in the block body.
|
||||
fn transaction_hashes_iter(&self) -> impl Iterator<Item = &B256> + '_ {
|
||||
self.transactions().iter().map(|tx| tx.tx_hash())
|
||||
}
|
||||
|
||||
/// Consume the block body and return a [`Vec`] of transactions.
|
||||
fn into_transactions(self) -> Vec<Self::Transaction>;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ where
|
||||
B: BlockTrait,
|
||||
{
|
||||
let block_hash = block_hash.unwrap_or_else(|| block.header().hash_slow());
|
||||
let transactions = block.body().transactions().iter().map(|tx| *tx.tx_hash()).collect();
|
||||
let transactions = block.body().transaction_hashes_iter().copied().collect();
|
||||
|
||||
from_block_with_transactions(
|
||||
block.length(),
|
||||
|
||||
Reference in New Issue
Block a user