feat: add find-transaction-by-hash (#14008)

This commit is contained in:
Matthias Seitz
2025-01-27 17:17:29 +01:00
committed by GitHub
parent cde951732e
commit 515c367c8b
2 changed files with 14 additions and 29 deletions

View File

@ -47,6 +47,13 @@ pub trait BlockBody:
self.transactions().iter()
}
/// Returns the transaction with the matching hash.
///
/// This is a convenience function for `transactions_iter().find()`
fn transaction_by_hash(&self, hash: &B256) -> Option<&Self::Transaction> {
self.transactions_iter().find(|tx| tx.tx_hash() == hash)
}
/// Clones the transactions in the block.
///
/// This is a convenience function for `transactions().to_vec()`