@@ -227,10 +227,12 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
227227 closedConnMutex .Unlock ()
228228 }()
229229
230+ log .Printf ("Processing batch with %d validations" , len (batchReq .Validations ))
230231 results := make ([]ExampleResponse , 0 , len (batchReq .Validations ))
231232
232233 // Process each validation silently and only send final results
233- for _ , msg := range batchReq .Validations {
234+ for i , msg := range batchReq .Validations {
235+ log .Printf ("Processing validation %d/%d: Name=%s, CID=%s" , i + 1 , len (batchReq .Validations ), msg .Name , msg .CID )
234236 // Normalize the message to handle both uppercase and lowercase field names
235237 msg .Normalize ()
236238
@@ -239,11 +241,15 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
239241 if salt == "" {
240242 salt , err = createRandomHash (conn )
241243 if err != nil {
242- // On error, report as Invalid with 0 elapsed time
243- if sendErr := sendWsResponseWithContext ("Invalid" , "Invalid" , "0" , msg .Name , msg .CID , msg .Bn , conn ); sendErr != nil {
244- // Connection lost, stop processing batch
245- return
246- }
244+ // On error, add Invalid result and continue
245+ results = append (results , ExampleResponse {
246+ Status : "Invalid" ,
247+ Message : "Invalid" ,
248+ Elapsed : "0" ,
249+ Name : msg .Name ,
250+ CID : msg .CID ,
251+ Bn : msg .Bn ,
252+ })
247253 continue
248254 }
249255 } else {
@@ -252,11 +258,15 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
252258
253259 proofJson , err := createProofRequest (salt , msg .CID , conn , msg .Name )
254260 if err != nil {
255- // On error, report as Invalid with 0 elapsed time
256- if sendErr := sendWsResponseWithContext ("Invalid" , "Invalid" , "0" , msg .Name , msg .CID , msg .Bn , conn ); sendErr != nil {
257- // Connection lost, stop processing batch
258- return
259- }
261+ // On error, add Invalid result and continue
262+ results = append (results , ExampleResponse {
263+ Status : "Invalid" ,
264+ Message : "Invalid" ,
265+ Elapsed : "0" ,
266+ Name : msg .Name ,
267+ CID : msg .CID ,
268+ Bn : msg .Bn ,
269+ })
260270 continue
261271 }
262272
@@ -282,11 +292,15 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
282292 }
283293
284294 if ! requestSent {
285- // If we couldn't send the request, report as Invalid
286- if sendErr := sendWsResponseWithContext ("Invalid" , "Invalid" , "0" , msg .Name , msg .CID , msg .Bn , conn ); sendErr != nil {
287- // Connection lost, stop processing batch
288- return
289- }
295+ // If we couldn't send the request, add Invalid result and continue
296+ results = append (results , ExampleResponse {
297+ Status : "Invalid" ,
298+ Message : "Invalid" ,
299+ Elapsed : "0" ,
300+ Name : msg .Name ,
301+ CID : msg .CID ,
302+ Bn : msg .Bn ,
303+ })
290304 continue
291305 }
292306
@@ -304,11 +318,14 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
304318 case <- ctx .Done ():
305319 // Timeout - report as Invalid
306320 elapsed := time .Since (startTime )
307- if sendErr := sendWsResponseWithContext ("Invalid" , "Invalid" , formatElapsed (elapsed ), msg .Name , msg .CID , msg .Bn , conn ); sendErr != nil {
308- // Connection lost, stop processing batch
309- cancel ()
310- return
311- }
321+ results = append (results , ExampleResponse {
322+ Status : "Invalid" ,
323+ Message : "Invalid" ,
324+ Elapsed : formatElapsed (elapsed ),
325+ Name : msg .Name ,
326+ CID : msg .CID ,
327+ Bn : msg .Bn ,
328+ })
312329 validationComplete = true
313330 default :
314331 status := localdata .GetStatus (salt ).Status
@@ -333,15 +350,10 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
333350 finalStatus = "Invalid"
334351 }
335352
336- if sendErr := sendWsResponseWithContext (finalStatus , finalStatus , formatElapsed (elapsed ), msg .Name , msg .CID , msg .Bn , conn ); sendErr != nil {
337- // Connection lost, stop processing batch
338- cancel ()
339- return
340- }
341-
353+ // Don't send individual responses - just collect for batch
342354 results = append (results , ExampleResponse {
343- Status : status ,
344- Message : status ,
355+ Status : finalStatus ,
356+ Message : finalStatus ,
345357 Elapsed : formatElapsed (elapsed ),
346358 Name : msg .Name ,
347359 CID : msg .CID ,
@@ -358,6 +370,7 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
358370 }
359371
360372 // Send final batch response with all results
373+ log .Printf ("Sending batch response with %d results" , len (results ))
361374 localdata .Lock .Lock ()
362375 err := conn .WriteJSON (BatchResponse {
363376 Type : "batch" ,
@@ -366,6 +379,8 @@ func handleBatchValidation(batchReq BatchRequest, conn *websocket.Conn) {
366379 localdata .Lock .Unlock ()
367380 if err != nil {
368381 log .Println ("Error writing batch response:" , err )
382+ } else {
383+ log .Printf ("Batch response sent successfully with %d results" , len (results ))
369384 }
370385}
371386
0 commit comments