@@ -18,7 +18,7 @@ use crate::eth::primitives::SlotIndex;
18
18
use crate :: eth:: primitives:: SlotSample ;
19
19
use crate :: eth:: primitives:: StoragePointInTime ;
20
20
use crate :: eth:: primitives:: TransactionExecution ;
21
- use crate :: eth:: primitives:: TransactionMined ;
21
+ use crate :: eth:: primitives:: TransactionStage ;
22
22
use crate :: eth:: storage:: PermanentStorage ;
23
23
use crate :: eth:: storage:: TemporaryStorage ;
24
24
use crate :: infra:: metrics;
@@ -226,21 +226,21 @@ impl StratusStorage {
226
226
// read from temp only if present
227
227
if point_in_time. is_present ( ) {
228
228
tracing:: debug!( storage = %label:: TEMP , %address, "reading account" ) ;
229
- let result = timed ( || self . temp . read_account ( address) ) . with ( |m| {
229
+ let temp_account = timed ( || self . temp . read_account ( address) ) . with ( |m| {
230
230
metrics:: inc_storage_read_account ( m. elapsed , label:: TEMP , point_in_time, m. result . is_ok ( ) ) ;
231
- } ) ;
232
- if let Some ( account) = result? {
231
+ } ) ? ;
232
+ if let Some ( account) = temp_account {
233
233
tracing:: debug!( storage = %label:: TEMP , %address, "account found in temporary storage" ) ;
234
234
return Ok ( account) ;
235
235
}
236
236
}
237
237
238
238
// always read from perm if necessary
239
239
tracing:: debug!( storage = %label:: PERM , %address, "reading account" ) ;
240
- let result = timed ( || self . perm . read_account ( address, point_in_time) ) . with ( |m| {
240
+ let perm_account = timed ( || self . perm . read_account ( address, point_in_time) ) . with ( |m| {
241
241
metrics:: inc_storage_read_account ( m. elapsed , label:: PERM , point_in_time, m. result . is_ok ( ) ) ;
242
- } ) ;
243
- match result? {
242
+ } ) ? ;
243
+ match perm_account {
244
244
Some ( account) => {
245
245
tracing:: debug!( %address, "account found in permanent storage" ) ;
246
246
Ok ( account)
@@ -263,21 +263,21 @@ impl StratusStorage {
263
263
// read from temp only if present
264
264
if point_in_time. is_present ( ) {
265
265
tracing:: debug!( storage = %label:: TEMP , %address, %index, "reading slot" ) ;
266
- let result = timed ( || self . temp . read_slot ( address, index) ) . with ( |m| {
266
+ let temp_slot = timed ( || self . temp . read_slot ( address, index) ) . with ( |m| {
267
267
metrics:: inc_storage_read_slot ( m. elapsed , label:: TEMP , point_in_time, m. result . is_ok ( ) ) ;
268
- } ) ;
269
- if let Some ( slot) = result? {
268
+ } ) ? ;
269
+ if let Some ( slot) = temp_slot {
270
270
tracing:: debug!( storage = %label:: TEMP , %address, %index, value = %slot. value, "slot found in temporary storage" ) ;
271
271
return Ok ( slot) ;
272
272
}
273
273
}
274
274
275
275
// always read from perm if necessary
276
276
tracing:: debug!( storage = %label:: PERM , %address, %index, ?point_in_time, "reading slot" ) ;
277
- let result = timed ( || self . perm . read_slot ( address, index, point_in_time) ) . with ( |m| {
277
+ let perm_slot = timed ( || self . perm . read_slot ( address, index, point_in_time) ) . with ( |m| {
278
278
metrics:: inc_storage_read_slot ( m. elapsed , label:: PERM , point_in_time, m. result . is_ok ( ) ) ;
279
- } ) ;
280
- match result? {
279
+ } ) ? ;
280
+ match perm_slot {
281
281
Some ( slot) => {
282
282
tracing:: debug!( %address, %index, value = %slot. value, "slot found in permanent storage" ) ;
283
283
Ok ( slot)
@@ -347,13 +347,27 @@ impl StratusStorage {
347
347
}
348
348
349
349
#[ tracing:: instrument( name = "storage::read_transaction" , skip_all, fields( hash) ) ]
350
- pub fn read_mined_transaction ( & self , hash : & Hash ) -> anyhow:: Result < Option < TransactionMined > > {
350
+ pub fn read_transaction ( & self , hash : & Hash ) -> anyhow:: Result < Option < TransactionStage > > {
351
351
Span :: with ( |s| s. rec_str ( "hash" , hash) ) ;
352
- tracing:: debug!( storage = %label:: PERM , %hash, "reading transaction" ) ;
353
352
354
- timed ( || self . perm . read_transaction ( hash) ) . with ( |m| {
355
- metrics:: inc_storage_read_mined_transaction ( m. elapsed , label:: PERM , m. result . is_ok ( ) ) ;
356
- } )
353
+ // read from temp
354
+ tracing:: debug!( storage = %label:: TEMP , %hash, "reading transaction" ) ;
355
+ let temp_tx = timed ( || self . temp . read_transaction ( hash) ) . with ( |m| {
356
+ metrics:: inc_storage_read_transaction ( m. elapsed , label:: TEMP , m. result . is_ok ( ) ) ;
357
+ } ) ?;
358
+ if let Some ( tx_temp) = temp_tx {
359
+ return Ok ( Some ( TransactionStage :: new_executed ( tx_temp) ) ) ;
360
+ }
361
+
362
+ // read from perm
363
+ tracing:: debug!( storage = %label:: PERM , %hash, "reading transaction" ) ;
364
+ let perm_tx = timed ( || self . perm . read_transaction ( hash) ) . with ( |m| {
365
+ metrics:: inc_storage_read_transaction ( m. elapsed , label:: PERM , m. result . is_ok ( ) ) ;
366
+ } ) ?;
367
+ match perm_tx {
368
+ Some ( tx) => Ok ( Some ( TransactionStage :: new_mined ( tx) ) ) ,
369
+ None => Ok ( None ) ,
370
+ }
357
371
}
358
372
359
373
#[ tracing:: instrument( name = "storage::read_logs" , skip_all) ]
0 commit comments