@@ -82,7 +82,9 @@ type MsgTypes struct {
82
82
var msgTypes = MsgTypes {}
83
83
84
84
func init () {
85
- onet .RegisterNewService (ServiceName , NewService )
85
+ if _ , err := onet .RegisterNewService (ServiceName , NewService ); err != nil {
86
+ log .Fatal ("Error registering service unlynx:" , err )
87
+ }
86
88
87
89
msgTypes .msgSurveyCreationQuery = network .RegisterMessage (& SurveyCreationQuery {})
88
90
network .RegisterMessage (& SurveyResponseQuery {})
@@ -158,13 +160,19 @@ func NewService(c *onet.Context) (onet.Service, error) {
158
160
func (s * Service ) Process (msg * network.Envelope ) {
159
161
if msg .MsgType .Equal (msgTypes .msgSurveyCreationQuery ) {
160
162
tmp := (msg .Msg ).(* SurveyCreationQuery )
161
- s .HandleSurveyCreationQuery (tmp )
163
+ if _ , cerr := s .HandleSurveyCreationQuery (tmp ); cerr != nil {
164
+ log .Fatal ("Error in HandleSurveyCreationQuery():" , cerr )
165
+ }
162
166
} else if msg .MsgType .Equal (msgTypes .msgSurveyResultsQuery ) {
163
167
tmp := (msg .Msg ).(* SurveyResultsQuery )
164
- s .HandleSurveyResultsQuery (tmp )
168
+ if _ , cerr := s .HandleSurveyResultsQuery (tmp ); cerr != nil {
169
+ log .Fatal ("Error in HandleSurveyResultsQuery():" , cerr )
170
+ }
165
171
} else if msg .MsgType .Equal (msgTypes .msgDDTfinished ) {
166
172
tmp := (msg .Msg ).(* DDTfinished )
167
- s .HandleDDTfinished (tmp )
173
+ if _ , cerr := s .HandleDDTfinished (tmp ); cerr != nil {
174
+ log .Fatal ("Error in HandleDDTfinished():" , cerr )
175
+ }
168
176
}
169
177
}
170
178
@@ -176,7 +184,9 @@ func (s *Service) PushData(resp *SurveyResponseQuery, proofs bool) {
176
184
dr .FromDpResponseToSend (v )
177
185
survey .InsertDpResponse (dr , proofs , survey .Query .GroupBy , survey .Query .Sum , survey .Query .Where )
178
186
}
179
- s .Survey .Put (string (resp .SurveyID ), survey )
187
+ if _ , err := s .Survey .Put (string (resp .SurveyID ), survey ); err != nil {
188
+ log .Fatal (err )
189
+ }
180
190
181
191
log .Lvl1 (s .ServerIdentity (), " uploaded response data for survey " , resp .SurveyID )
182
192
}
@@ -213,7 +223,7 @@ func (s *Service) HandleSurveyCreationQuery(recq *SurveyCreationQuery) (network.
213
223
precomputeShuffle := libunlynxshuffle .PrecomputationWritingForShuffling (recq .AppFlag , gobFile , s .ServerIdentity ().String (), surveySecret , recq .Roster .Aggregate , lineSize )
214
224
215
225
// survey instantiation
216
- s .Survey .Put ((string )(recq .SurveyID ), Survey {
226
+ if _ , err := s .Survey .Put ((string )(recq .SurveyID ), Survey {
217
227
Store : libunlynxstore .NewStore (),
218
228
Query : * recq ,
219
229
SurveySecretKey : surveySecret ,
@@ -222,7 +232,9 @@ func (s *Service) HandleSurveyCreationQuery(recq *SurveyCreationQuery) (network.
222
232
SurveyChannel : make (chan int , 100 ),
223
233
DpChannel : make (chan int , 100 ),
224
234
DDTChannel : make (chan int , 100 ),
225
- })
235
+ }); err != nil {
236
+ log .Fatal (err )
237
+ }
226
238
227
239
log .Lvl1 (s .ServerIdentity (), " created the survey " , recq .SurveyID )
228
240
// if it is a app download the data from the test file
@@ -285,7 +297,9 @@ func (s *Service) HandleSurveyResultsQuery(resq *SurveyResultsQuery) (network.Me
285
297
286
298
survey := castToSurvey (s .Survey .Get ((string )(resq .SurveyID )))
287
299
survey .Query .ClientPubKey = resq .ClientPublic
288
- s .Survey .Put (string (resq .SurveyID ), survey )
300
+ if _ , err := s .Survey .Put (string (resq .SurveyID ), survey ); err != nil {
301
+ log .Fatal (err )
302
+ }
289
303
290
304
if resq .IntraMessage == false {
291
305
resq .IntraMessage = true
@@ -294,18 +308,24 @@ func (s *Service) HandleSurveyResultsQuery(resq *SurveyResultsQuery) (network.Me
294
308
if err != nil {
295
309
log .Error ("broadcasting error " , err )
296
310
}
297
- s .StartService (resq .SurveyID , true )
311
+ if err := s .StartService (resq .SurveyID , true ); err != nil {
312
+ log .Fatal ("Server (" , s .ServerIdentity ().String (), ") error during StartService():" , err )
313
+ }
298
314
299
315
log .Lvl1 (s .ServerIdentity (), " completed the query processing..." )
300
316
301
317
survey := castToSurvey (s .Survey .Get ((string )(resq .SurveyID )))
302
318
results := survey .PullDeliverableResults (false , libunlynx.CipherText {})
303
- s .Survey .Put (string (resq .SurveyID ), survey )
319
+ if _ , err := s .Survey .Put (string (resq .SurveyID ), survey ); err != nil {
320
+ log .Fatal (err )
321
+ }
304
322
305
323
return & ServiceResult {Results : results }, nil
306
324
}
307
325
308
- s .StartService (resq .SurveyID , false )
326
+ if err := s .StartService (resq .SurveyID , false ); err != nil {
327
+ log .Fatal ("Server (" , s .ServerIdentity ().String (), ") error during StartService():" , err )
328
+ }
309
329
return nil , nil
310
330
}
311
331
@@ -320,7 +340,9 @@ func (s *Service) HandleDDTfinished(recq *DDTfinished) (network.Message, error)
320
340
321
341
// NewProtocol creates a protocol instance executed by all nodes
322
342
func (s * Service ) NewProtocol (tn * onet.TreeNodeInstance , conf * onet.GenericConfig ) (onet.ProtocolInstance , error ) {
323
- tn .SetConfig (conf )
343
+ if err := tn .SetConfig (conf ); err != nil {
344
+ log .Fatal ("Error during SetConfig in the NewProtocol():" , err )
345
+ }
324
346
325
347
var pi onet.ProtocolInstance
326
348
var err error
@@ -348,7 +370,9 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi
348
370
toShuffleCV , survey .Lengths = protocolsunlynx .ProcessResponseToMatrixCipherText (dpResponses )
349
371
shuffle .ShuffleTarget = & toShuffleCV
350
372
351
- s .Survey .Put (string (target ), survey )
373
+ if _ , err := s .Survey .Put (string (target ), survey ); err != nil {
374
+ log .Fatal (err )
375
+ }
352
376
}
353
377
354
378
case protocolsunlynx .DeterministicTaggingProtocolName :
@@ -372,7 +396,9 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi
372
396
shuffledClientResponses = append (queryWhereToTag , shuffledClientResponses ... )
373
397
tmpDeterministicTOS := protocolsunlynx .ProcessResponseToCipherVector (shuffledClientResponses )
374
398
survey .TargetOfSwitch = shuffledClientResponses
375
- s .Survey .Put (string (target ), survey )
399
+ if _ , err := s .Survey .Put (string (target ), survey ); err != nil {
400
+ log .Fatal (err )
401
+ }
376
402
377
403
hashCreation .TargetOfSwitch = & tmpDeterministicTOS
378
404
}
@@ -385,7 +411,9 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi
385
411
386
412
// waits for all other nodes to finish the tagging phase
387
413
groupedData := survey .PullLocallyAggregatedResponses ()
388
- s .Survey .Put (string (target ), survey )
414
+ if _ , err := s .Survey .Put (string (target ), survey ); err != nil {
415
+ log .Fatal (err )
416
+ }
389
417
390
418
collectiveAggr := pi .(* protocolsunlynx.CollectiveAggregationProtocol )
391
419
collectiveAggr .GroupedData = & groupedData
@@ -453,7 +481,9 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi
453
481
tmp := survey .Query .ClientPubKey
454
482
keySwitch .TargetPublicKey = & tmp
455
483
456
- s .Survey .Put (string (target ), survey )
484
+ if _ , err := s .Survey .Put (string (target ), survey ); err != nil {
485
+ log .Fatal (err )
486
+ }
457
487
}
458
488
default :
459
489
return nil , errors .New ("Service attempts to start an unknown protocol: " + tn .ProtocolName () + "." )
@@ -474,12 +504,23 @@ func (s *Service) StartProtocol(name string, targetSurvey SurveyID) (onet.Protoc
474
504
475
505
pi , err := s .NewProtocol (tn , & conf )
476
506
if err != nil {
477
- log .Fatal ("Error running" + name + ":" , err )
507
+ log .Fatal ("Error running " + name + " :" , err )
478
508
}
479
509
480
- s .RegisterProtocolInstance (pi )
481
- go pi .Dispatch ()
482
- go pi .Start ()
510
+ if err := s .RegisterProtocolInstance (pi ); err != nil {
511
+ log .Fatal ("Error registering protocol <" , name , ">:" , err )
512
+ }
513
+
514
+ go func () {
515
+ if err := pi .Dispatch (); err != nil {
516
+ log .Fatal ("Error in Dispatch for protocol <" , name , ">:" , err )
517
+ }
518
+ }()
519
+ go func () {
520
+ if err := pi .Start (); err != nil {
521
+ log .Fatal ("Error in Start for protocol <" , name , ">:" , err )
522
+ }
523
+ }()
483
524
484
525
return pi , err
485
526
}
@@ -549,7 +590,10 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error {
549
590
if root == true && libunlynx .DIFFPRI == true {
550
591
start := libunlynx .StartTimer (s .ServerIdentity ().String () + "_DROPhase" )
551
592
552
- s .DROPhase (target .Query .SurveyID )
593
+ err := s .DROPhase (target .Query .SurveyID )
594
+ if err != nil {
595
+ log .Fatal ("Error in the DRO Phase:" , err )
596
+ }
553
597
554
598
libunlynx .EndTimer (start )
555
599
}
@@ -558,7 +602,10 @@ func (s *Service) StartService(targetSurvey SurveyID, root bool) error {
558
602
if root == true {
559
603
start := libunlynx .StartTimer (s .ServerIdentity ().String () + "_KeySwitchingPhase" )
560
604
561
- s .KeySwitchingPhase (target .Query .SurveyID )
605
+ err := s .KeySwitchingPhase (target .Query .SurveyID )
606
+ if err != nil {
607
+ log .Fatal ("Error in the KeySwitching Phase:" , err )
608
+ }
562
609
563
610
libunlynx .EndTimer (start )
564
611
}
@@ -583,7 +630,9 @@ func (s *Service) ShufflingPhase(targetSurvey SurveyID) error {
583
630
shufflingResult := protocolsunlynx .MatrixCipherTextToProcessResponse (tmpShufflingResult , castToSurvey (s .Survey .Get ((string )(targetSurvey ))).Lengths )
584
631
585
632
survey .PushShuffledProcessResponses (shufflingResult )
586
- s .Survey .Put (string (targetSurvey ), survey )
633
+ if _ , err := s .Survey .Put (string (targetSurvey ), survey ); err != nil {
634
+ log .Fatal (err )
635
+ }
587
636
return err
588
637
}
589
638
@@ -619,7 +668,9 @@ func (s *Service) TaggingPhase(targetSurvey SurveyID) error {
619
668
}
620
669
621
670
survey .PushDeterministicFilteredResponses (filteredResponses , s .ServerIdentity ().String (), survey .Query .Proofs )
622
- s .Survey .Put (string (targetSurvey ), survey )
671
+ if _ , err := s .Survey .Put (string (targetSurvey ), survey ); err != nil {
672
+ log .Fatal (err )
673
+ }
623
674
return err
624
675
}
625
676
@@ -633,7 +684,9 @@ func (s *Service) AggregationPhase(targetSurvey SurveyID) error {
633
684
634
685
survey := castToSurvey (s .Survey .Get ((string )(targetSurvey )))
635
686
survey .PushCothorityAggregatedFilteredResponses (cothorityAggregatedData .GroupedData )
636
- s .Survey .Put (string (targetSurvey ), survey )
687
+ if _ , err := s .Survey .Put (string (targetSurvey ), survey ); err != nil {
688
+ log .Fatal (err )
689
+ }
637
690
return nil
638
691
}
639
692
@@ -650,7 +703,9 @@ func (s *Service) DROPhase(targetSurvey SurveyID) error {
650
703
shufflingResult := protocolsunlynx .MatrixCipherTextToProcessResponse (tmpShufflingResult , survey .Lengths )
651
704
652
705
survey .Noise = shufflingResult [0 ].AggregatingAttributes [0 ]
653
- s .Survey .Put (string (targetSurvey ), survey )
706
+ if _ , err := s .Survey .Put (string (targetSurvey ), survey ); err != nil {
707
+ log .Fatal (err )
708
+ }
654
709
return nil
655
710
}
656
711
@@ -667,7 +722,9 @@ func (s *Service) KeySwitchingPhase(targetSurvey SurveyID) error {
667
722
keySwitchedAggregatedResponses := protocolsunlynx .CipherVectorToFilteredResponse (tmpKeySwitchedAggregatedResponses , survey .Lengths )
668
723
669
724
survey .PushQuerierKeyEncryptedResponses (keySwitchedAggregatedResponses )
670
- s .Survey .Put (string (targetSurvey ), survey )
725
+ if _ , err := s .Survey .Put (string (targetSurvey ), survey ); err != nil {
726
+ log .Fatal (err )
727
+ }
671
728
return err
672
729
}
673
730
0 commit comments