mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: ChainStorageReader (#12836)
This commit is contained in:
@ -15,6 +15,7 @@ use reth_primitives::{
|
||||
BlockWithSenders, NodePrimitives, Receipts, SealedBlock, SealedBlockWithSenders, SealedHeader,
|
||||
TransactionMeta, TransactionSigned,
|
||||
};
|
||||
use reth_primitives_traits::BlockBody as _;
|
||||
use reth_storage_api::StateProviderBox;
|
||||
use reth_trie::{updates::TrieUpdates, HashedPostState};
|
||||
use std::{collections::BTreeMap, sync::Arc, time::Instant};
|
||||
@ -547,8 +548,13 @@ where
|
||||
/// Returns a `TransactionSigned` for the given `TxHash` if found.
|
||||
pub fn transaction_by_hash(&self, hash: TxHash) -> Option<TransactionSigned> {
|
||||
for block_state in self.canonical_chain() {
|
||||
if let Some(tx) =
|
||||
block_state.block_ref().block().body.transactions().find(|tx| tx.hash() == hash)
|
||||
if let Some(tx) = block_state
|
||||
.block_ref()
|
||||
.block()
|
||||
.body
|
||||
.transactions()
|
||||
.iter()
|
||||
.find(|tx| tx.hash() == hash)
|
||||
{
|
||||
return Some(tx.clone())
|
||||
}
|
||||
@ -568,6 +574,7 @@ where
|
||||
.block()
|
||||
.body
|
||||
.transactions()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, tx)| tx.hash() == tx_hash)
|
||||
{
|
||||
@ -748,6 +755,7 @@ impl<N: NodePrimitives> BlockState<N> {
|
||||
.block()
|
||||
.body
|
||||
.transactions()
|
||||
.iter()
|
||||
.find(|tx| tx.hash() == hash)
|
||||
.cloned()
|
||||
})
|
||||
@ -764,6 +772,7 @@ impl<N: NodePrimitives> BlockState<N> {
|
||||
.block()
|
||||
.body
|
||||
.transactions()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, tx)| tx.hash() == tx_hash)
|
||||
.map(|(index, tx)| {
|
||||
|
||||
Reference in New Issue
Block a user