@@ -18,7 +18,7 @@ use reth_primitives_traits::{
1818} ;
1919use reth_storage_api:: StateProviderBox ;
2020use reth_trie:: { updates:: TrieUpdatesSorted , HashedPostStateSorted , TrieInputSorted } ;
21- use std:: { collections:: BTreeMap , sync:: Arc , time:: Instant } ;
21+ use std:: { collections:: BTreeMap , ops :: Deref , sync:: Arc , time:: Instant } ;
2222use tokio:: sync:: { broadcast, watch} ;
2323
2424/// Size of the broadcast channel used to notify canonical state events.
@@ -634,6 +634,8 @@ impl<N: NodePrimitives> BlockState<N> {
634634 /// We assume that the `Receipts` in the executed block `ExecutionOutcome`
635635 /// has only one element corresponding to the executed block associated to
636636 /// the state.
637+ ///
638+ /// This clones the vector of receipts. To avoid it, use [`Self::executed_block_receipts_ref`].
637639 pub fn executed_block_receipts ( & self ) -> Vec < N :: Receipt > {
638640 let receipts = self . receipts ( ) ;
639641
@@ -646,6 +648,22 @@ impl<N: NodePrimitives> BlockState<N> {
646648 receipts. first ( ) . cloned ( ) . unwrap_or_default ( )
647649 }
648650
651+ /// Returns a slice of `Receipt` of executed block that determines the state.
652+ /// We assume that the `Receipts` in the executed block `ExecutionOutcome`
653+ /// has only one element corresponding to the executed block associated to
654+ /// the state.
655+ pub fn executed_block_receipts_ref ( & self ) -> & [ N :: Receipt ] {
656+ let receipts = self . receipts ( ) ;
657+
658+ debug_assert ! (
659+ receipts. len( ) <= 1 ,
660+ "Expected at most one block's worth of receipts, found {}" ,
661+ receipts. len( )
662+ ) ;
663+
664+ receipts. first ( ) . map ( |receipts| receipts. deref ( ) ) . unwrap_or_default ( )
665+ }
666+
649667 /// Returns a vector of __parent__ `BlockStates`.
650668 ///
651669 /// The block state order in the output vector is newest to oldest (highest to lowest):
0 commit comments