Skip to content

Commit 413d3cd

Browse files
committed
feat: sequencial send msg and recv response
1 parent ce07c08 commit 413d3cd

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

batcher/aligned-sdk/src/sdk.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ async fn _submit_multiple(
297297
"verification_data".to_string(),
298298
));
299299
}
300+
if verification_data.len() > 10000 { //TODO unhardcode value
301+
return Err(errors::SubmitError::GenericError(
302+
"Trying to submit too many proofs at once".to_string(),
303+
));
304+
}
305+
300306
let ws_write_clone = ws_write.clone();
301307

302308
let response_stream: ResponseStream =
@@ -308,28 +314,21 @@ async fn _submit_multiple(
308314

309315
let (sender_channel, receiver_channel) = mpsc::channel(50000); //TODO Magic number
310316

311-
let (send_result, receive_result) = tokio::join!(
312-
send_messages(
313-
ws_write,
314-
payment_service_addr,
315-
verification_data,
316-
max_fees,
317-
wallet,
318-
nonce,
319-
sender_channel,
320-
),
321-
receive(
322-
response_stream,
323-
receiver_channel
324-
),
325-
);
317+
// done sequencial
318+
// added size check to avoid sequencial is too big
319+
// chequeando el nonce del ultimo, puedo cortar la conexión cuando recibo su respuesta
320+
// agregar nonce en la respuesta del batcher al sender
321+
// sacar el mensaje de que la proof es una replacement
322+
323+
let result = async {
324+
send_messages(ws_write, payment_service_addr, verification_data, max_fees, wallet, nonce, sender_channel).await?;
325+
receive(response_stream, receiver_channel).await
326+
}.await;
326327

327328
// Close connection
328329
info!("Closing WS connection");
329330
ws_write_clone.lock().await.close().await?;
330-
331-
send_result?;
332-
return receive_result;
331+
result
333332
}
334333

335334
/// Submits a proof to the batcher to be verified in Aligned and waits for the verification on-chain.

0 commit comments

Comments
 (0)