@@ -65,23 +65,15 @@ pub async fn send_messages(
6565 . map_err ( SubmitError :: WebSocketConnectionError ) ?;
6666
6767 debug ! ( "{:?} Message sent" , idx) ;
68-
68+
6969 // Save the verification data commitment to read its response later
7070 sent_verification_data. push ( verification_data) ;
7171 }
7272
7373 info ! ( "All messages sent" ) ;
74- Ok ( sent_verification_data)
74+ Ok ( sent_verification_data)
7575}
7676
77-
78- // Instead of using a channel, use a storage.
79- // Using a
80- // From there, you can match received messages to the ones you sent.
81-
82- // TODO missing analyzing which is the last expected nonce.
83- // When received message of last expected nonce, i can exit this function
84-
8577// Receives the array of proofs sent
8678// Reads the WS responses
8779// Matches each response with the corresponding proof sent
@@ -105,24 +97,19 @@ pub async fn receive(
10597 ) ) ;
10698 }
10799 return Err ( SubmitError :: GenericError (
108- "Connection was closed before receive() processed all sent messages "
109- . to_string ( ) ,
100+ "Connection was closed before receive() processed all sent messages " . to_string ( ) ,
110101 ) ) ;
111102 }
112-
113- let batch_inclusion_data_message = handle_batcher_response (
114- msg,
115- ) . await ?;
103+
104+ let batch_inclusion_data_message = handle_batcher_response ( msg) . await ?;
116105
117106 let related_verification_data = match_batcher_response_with_stored_verification_data (
118107 & batch_inclusion_data_message,
119108 & mut sent_verification_data,
120109 ) ?;
121-
122- let aligned_verification_data = process_batcher_response (
123- & batch_inclusion_data_message,
124- & related_verification_data,
125- ) ?;
110+
111+ let aligned_verification_data =
112+ process_batcher_response ( & batch_inclusion_data_message, & related_verification_data) ?;
126113
127114 aligned_submitted_data. push ( aligned_verification_data) ;
128115 info ! ( "Message response handled succesfully" ) ;
@@ -136,13 +123,11 @@ pub async fn receive(
136123 Ok ( aligned_submitted_data)
137124}
138125
139- async fn handle_batcher_response (
140- msg : Message ,
141- ) -> Result < BatchInclusionData , SubmitError > {
142-
126+ async fn handle_batcher_response ( msg : Message ) -> Result < BatchInclusionData , SubmitError > {
143127 let data = msg. into_data ( ) ;
144128 match cbor_deserialize ( data. as_slice ( ) ) {
145- Ok ( ResponseMessage :: BatchInclusionData ( batch_inclusion_data) ) => { //OK case. Proofs was valid and it was included in this batch.
129+ Ok ( ResponseMessage :: BatchInclusionData ( batch_inclusion_data) ) => {
130+ //OK case. Proofs was valid and it was included in this batch.
146131 return Ok ( batch_inclusion_data) ;
147132 }
148133 Ok ( ResponseMessage :: InvalidNonce ) => {
@@ -193,14 +178,17 @@ async fn handle_batcher_response(
193178 expected_addr,
194179 ) ) ;
195180 }
196- Ok ( ResponseMessage :: InvalidProof ( reason) ) => {
181+ Ok ( ResponseMessage :: InvalidProof ( reason) ) => {
197182 error ! ( "Batcher responded with invalid proof: {}" , reason) ;
198183 return Err ( SubmitError :: InvalidProof ( reason) ) ;
199184 }
200185 Ok ( ResponseMessage :: CreateNewTaskError ( merkle_root, error) ) => {
201186 error ! ( "Batcher responded with create new task error: {}" , error) ;
202187 return Err ( SubmitError :: BatchSubmissionFailed (
203- "Could not create task with merkle root " . to_owned ( ) + & merkle_root + ", failed with error: " + & error,
188+ "Could not create task with merkle root " . to_owned ( )
189+ + & merkle_root
190+ + ", failed with error: "
191+ + & error,
204192 ) ) ;
205193 }
206194 Ok ( ResponseMessage :: ProtocolVersion ( _) ) => {
@@ -216,7 +204,7 @@ async fn handle_batcher_response(
216204 }
217205 Ok ( ResponseMessage :: Error ( e) ) => {
218206 error ! ( "Batcher responded with error: {}" , e) ;
219- return Err ( SubmitError :: GenericError ( e) )
207+ return Err ( SubmitError :: GenericError ( e) ) ;
220208 }
221209 Err ( e) => {
222210 error ! ( "Error while deserializing batch inclusion data: {}" , e) ;
0 commit comments