@@ -76,42 +76,26 @@ impl BlobStore for InMemoryBlobStore {
7676
7777 // Retrieves the decoded blob data for the given transaction hash.
7878 fn get ( & self , tx : B256 ) -> Result < Option < BlobTransactionSidecar > , BlobStoreError > {
79- let store = self . inner . store . read ( ) ;
80- Ok ( store. get ( & tx) . cloned ( ) )
79+ Ok ( self . inner . store . read ( ) . get ( & tx) . cloned ( ) )
8180 }
8281
8382 fn contains ( & self , tx : B256 ) -> Result < bool , BlobStoreError > {
84- let store = self . inner . store . read ( ) ;
85- Ok ( store. contains_key ( & tx) )
83+ Ok ( self . inner . store . read ( ) . contains_key ( & tx) )
8684 }
8785
8886 fn get_all (
8987 & self ,
9088 txs : Vec < B256 > ,
9189 ) -> Result < Vec < ( B256 , BlobTransactionSidecar ) > , BlobStoreError > {
92- let mut items = Vec :: with_capacity ( txs. len ( ) ) ;
9390 let store = self . inner . store . read ( ) ;
94- for tx in txs {
95- if let Some ( item) = store. get ( & tx) {
96- items. push ( ( tx, item. clone ( ) ) ) ;
97- }
98- }
99-
100- Ok ( items)
91+ Ok ( txs. into_iter ( ) . filter_map ( |tx| store. get ( & tx) . map ( |item| ( tx, item. clone ( ) ) ) ) . collect ( ) )
10192 }
10293
10394 fn get_exact ( & self , txs : Vec < B256 > ) -> Result < Vec < BlobTransactionSidecar > , BlobStoreError > {
104- let mut items = Vec :: with_capacity ( txs. len ( ) ) ;
10595 let store = self . inner . store . read ( ) ;
106- for tx in txs {
107- if let Some ( item) = store. get ( & tx) {
108- items. push ( item. clone ( ) ) ;
109- } else {
110- return Err ( BlobStoreError :: MissingSidecar ( tx) )
111- }
112- }
113-
114- Ok ( items)
96+ txs. into_iter ( )
97+ . map ( |tx| store. get ( & tx) . cloned ( ) . ok_or_else ( || BlobStoreError :: MissingSidecar ( tx) ) )
98+ . collect ( )
11599 }
116100
117101 fn get_by_versioned_hashes (
0 commit comments