@@ -29,6 +29,9 @@ pub type ResponseStream = TryFilter<
2929 fn ( & Message ) -> Ready < bool > ,
3030> ;
3131
32+ // Sends the proofs to the batcher via WS
33+ // Stores the proofs sent in an array
34+ // Returns the array
3235pub async fn send_messages (
3336 ws_write : Arc < Mutex < SplitSink < WebSocketStream < MaybeTlsStream < TcpStream > > , Message > > > ,
3437 payment_service_addr : Address ,
@@ -73,10 +76,16 @@ pub async fn send_messages(
7376
7477
7578// Instead of using a channel, use a storage.
79+ // Using a
7680// From there, you can match received messages to the ones you sent.
7781
7882// TODO missing analyzing which is the last expected nonce.
7983// When received message of last expected nonce, i can exit this function
84+
85+ // Receives the array of proofs sent
86+ // Reads the WS responses
87+ // Matches each response with the corresponding proof sent
88+ // finishes when the last proof sent receives its response
8089pub async fn receive (
8190 response_stream : Arc < Mutex < ResponseStream > > ,
8291 mut sent_verification_data : Vec < NoncedVerificationData > ,
@@ -217,8 +226,8 @@ async fn handle_batcher_response(
217226}
218227
219228// Used to match the message received from the batcher,
220- // a BatchInclusionData corresponding to the data you need to verify your proof is in a batch
221- // with the NoncedVerificationData you sent, used to verify the proof was indeed included in the batch
229+ // with the NoncedVerificationData you sent
230+ // This is used to verify the proof you sent was indeed included in the batch
222231fn match_batcher_response_with_stored_verification_data (
223232 batch_inclusion_data : & BatchInclusionData ,
224233 sent_verification_data : & mut Vec < NoncedVerificationData > ,
@@ -241,6 +250,9 @@ fn match_batcher_response_with_stored_verification_data(
241250 Err ( SubmitError :: InvalidProofInclusionData )
242251}
243252
253+ // Returns the biggest nonce from the sent verification data
254+ // Used to know which is the last proof sent to the Batcher,
255+ // to know when to stop reading the WS for responses
244256fn get_biggest_nonce ( sent_verification_data : & Vec < NoncedVerificationData > ) -> U256 {
245257 let mut biggest_nonce = U256 :: zero ( ) ;
246258 for verification_data in sent_verification_data. iter ( ) {
0 commit comments