@@ -12,7 +12,7 @@ use std::sync::Arc;
12
12
use thiserror:: Error ;
13
13
use tokio:: sync:: RwLock ;
14
14
use tokio:: sync:: mpsc;
15
- use tracing:: error;
15
+ use tracing:: { debug , error} ;
16
16
#[ derive( Debug , Error ) ]
17
17
pub enum FlashblocksError {
18
18
#[ error( "Missing base payload for initial flashblock" ) ]
@@ -162,16 +162,26 @@ impl FlashblocksService {
162
162
) -> Result < Option < OpExecutionPayloadEnvelopeV3 > , FlashblocksError > {
163
163
// consume the best payload and reset the builder
164
164
let payload = {
165
+ debug ! (
166
+ message =
167
+ "Acquiring best payload write lock: get_best_payload() to use best_payload"
168
+ ) ;
165
169
let mut builder = self . best_payload . write ( ) . await ;
166
170
std:: mem:: take ( & mut * builder) . into_envelope ( ) ?
167
171
} ;
172
+ debug ! (
173
+ message = "Acquiring best payload write lock: get_best_payload() to reset best_payload"
174
+ ) ;
168
175
* self . best_payload . write ( ) . await = FlashblockBuilder :: new ( ) ;
169
176
170
177
Ok ( Some ( payload) )
171
178
}
172
179
173
180
pub async fn set_current_payload_id ( & self , payload_id : PayloadId ) {
174
181
tracing:: debug!( message = "Setting current payload ID" , payload_id = %payload_id) ;
182
+ debug ! (
183
+ message = "Acquiring current payload id write lock: set_current_payload_id() to use current_payload_id"
184
+ ) ;
175
185
* self . current_payload_id . write ( ) . await = payload_id;
176
186
}
177
187
@@ -185,12 +195,19 @@ impl FlashblocksService {
185
195
) ;
186
196
187
197
// make sure the payload id matches the current payload id
198
+ debug ! (
199
+ message = "Acquiring current payload id read lock: on_event() to use current_payload_id"
200
+ ) ;
188
201
let current_payload_id = * self . current_payload_id . read ( ) . await ;
189
202
if current_payload_id != payload. payload_id {
190
203
error ! ( message = "Payload ID mismatch" , current_payload_id = %current_payload_id, payload_id = %payload. payload_id) ;
191
204
return ;
192
205
}
193
206
207
+ debug ! (
208
+ message =
209
+ "Acquiring best payload write lock: on_event() to extend best_payload"
210
+ ) ;
194
211
if let Err ( e) = self . best_payload . write ( ) . await . extend ( payload. clone ( ) ) {
195
212
error ! ( message = "Failed to extend payload" , error = %e) ;
196
213
} else {
0 commit comments