Skip to content

Commit cf96452

Browse files
committed
feat: send a batch reset to users of the batch when flushing
1 parent c59f69a commit cf96452

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

crates/batcher/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,19 @@ impl Batcher {
20412041

20422042
self.flush_queue_and_clear_nonce_cache().await;
20432043

2044+
for entry in finalized_batch {
2045+
if let Some(ws_sink) = entry.messaging_sink.as_ref() {
2046+
tokio::spawn(send_message(
2047+
ws_sink.clone(),
2048+
SubmitProofResponseMessage::BatchReset,
2049+
));
2050+
} else {
2051+
warn!(
2052+
"Websocket sink was found empty. This should only happen in tests"
2053+
);
2054+
}
2055+
}
2056+
20442057
return Err(BatcherError::StateCorruptedAndFlushed(format!(
20452058
"Queue and user states flushed due to insufficient balance for user {:?}",
20462059
address
@@ -2082,7 +2095,10 @@ impl Batcher {
20822095
let mut batch_state_lock = self.batch_state.lock().await;
20832096
for (entry, _) in batch_state_lock.batch_queue.iter() {
20842097
if let Some(ws_sink) = entry.messaging_sink.as_ref() {
2085-
send_message(ws_sink.clone(), SubmitProofResponseMessage::BatchReset).await;
2098+
tokio::spawn(send_message(
2099+
ws_sink.clone(),
2100+
SubmitProofResponseMessage::BatchReset,
2101+
));
20862102
} else {
20872103
warn!("Websocket sink was found empty. This should only happen in tests");
20882104
}

0 commit comments

Comments
 (0)