1
1
use std:: { collections:: BTreeSet , sync:: Arc } ;
2
2
3
3
use futures:: TryFutureExt ;
4
- use miden_node_utils:: { ErrorReport , FlattenResult , tracing:: OpenTelemetrySpanExt } ;
4
+ use miden_node_utils:: { ErrorReport , tracing:: OpenTelemetrySpanExt } ;
5
5
use miden_objects:: {
6
6
TransactionInputError , Word ,
7
7
account:: { Account , AccountId } ,
@@ -20,7 +20,7 @@ use miden_tx::{
20
20
} ;
21
21
use rand:: seq:: SliceRandom ;
22
22
use tokio:: task:: JoinError ;
23
- use tracing:: instrument;
23
+ use tracing:: { Instrument , instrument, instrument :: Instrumented } ;
24
24
25
25
use crate :: { COMPONENT , block_producer:: BlockProducerClient , state:: TransactionCandidate } ;
26
26
@@ -71,32 +71,42 @@ impl NtxContext {
71
71
72
72
// Work-around for `TransactionExecutor` not being `Send`.
73
73
tokio:: task:: spawn_blocking ( move || {
74
- let rt = tokio:: runtime:: Builder :: new_current_thread ( )
75
- . enable_all ( )
76
- . build ( )
77
- . expect ( "runtime should be built" ) ;
78
-
79
- rt. block_on ( async move {
80
- let mut notes = notes
81
- . into_iter ( )
82
- . map ( |note| InputNote :: Unauthenticated { note : note. into ( ) } )
83
- . collect :: < Vec < _ > > ( ) ;
84
- // We shuffle the notes here to prevent having a failing note always in front.
85
- notes. shuffle ( & mut rand:: rng ( ) ) ;
86
- let notes = InputNotes :: new ( notes) . map_err ( NtxError :: InputNotes ) ?;
87
-
88
- let data_store = NtxDataStore :: new ( account, self . genesis_header . clone ( ) ) ;
89
-
90
- self . filter_notes ( & data_store, notes)
91
- . and_then ( |notes| self . execute ( & data_store, notes) )
92
- . and_then ( |tx| self . prove ( tx) )
93
- . and_then ( |tx| self . submit ( tx) )
94
- . await
95
- } )
74
+ {
75
+ {
76
+ let rt = tokio:: runtime:: Builder :: new_current_thread ( )
77
+ . enable_all ( )
78
+ . build ( )
79
+ . expect ( "runtime should be built" ) ;
80
+
81
+ rt. block_on (
82
+ async move {
83
+ let mut notes = notes
84
+ . into_iter ( )
85
+ . map ( |note| InputNote :: Unauthenticated { note : note. into ( ) } )
86
+ . collect :: < Vec < _ > > ( ) ;
87
+ // We shuffle the notes here to prevent having a failing note always in
88
+ // front.
89
+ notes. shuffle ( & mut rand:: rng ( ) ) ;
90
+ let notes = InputNotes :: new ( notes) . map_err ( NtxError :: InputNotes ) ?;
91
+
92
+ let data_store =
93
+ NtxDataStore :: new ( account, self . genesis_header . clone ( ) ) ;
94
+
95
+ self . filter_notes ( & data_store, notes)
96
+ . and_then ( |notes| self . execute ( & data_store, notes) )
97
+ . and_then ( |tx| self . prove ( tx) )
98
+ . and_then ( |tx| self . submit ( tx) )
99
+ . await
100
+ }
101
+ . in_current_span ( ) ,
102
+ )
103
+ }
104
+ }
105
+ . in_current_span ( )
96
106
} )
97
- . map_err ( NtxError :: Panic )
98
107
. await
99
- . flatten_result ( )
108
+ . map_err ( NtxError :: Panic )
109
+ . and_then ( Instrumented :: into_inner)
100
110
. inspect_err ( |err| tracing:: Span :: current ( ) . set_error ( err) )
101
111
}
102
112
0 commit comments