Skip to content

Commit

Permalink
Fixed init() in constants.go mistake in condition
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoAndreSa committed Mar 11, 2020
1 parent abbe277 commit 3a7f339
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 27 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ require (
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.3
go.dedis.ch/kyber/v3 v3.0.12
go.dedis.ch/onet/v3 v3.1.0
go.dedis.ch/onet/v3 v3.1.1
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 // indirect
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
)

//replace go.dedis.ch/onet/v3 => ../../../go.dedis.ch/onet
2 changes: 1 addition & 1 deletion lib/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func init() {
tmp, err := time.ParseDuration(os.Getenv("MEDCO_TIMEOUT"))
if err != nil {
if err == nil {
TIMEOUT = tmp
}
}
Expand Down
2 changes: 1 addition & 1 deletion protocols/collective_aggregation_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (p *CollectiveAggregationProtocol) aggregationAnnouncementPhase() error {
}
}
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <dataReferenceMessage> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <dataReferenceMessage> on time.")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions protocols/deterministic_tagging_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (p *DeterministicTaggingProtocol) Dispatch() error {
select {
case deterministicTaggingTargetBytesBef = <-p.PreviousNodeInPathChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <deterministicTaggingTargetBytesBef> (first round) on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <deterministicTaggingTargetBytesBef> (first round) on time.")
}

deterministicTaggingTargetBef := DeterministicTaggingMessage{Data: make([]libunlynx.CipherText, 0)}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (p *DeterministicTaggingProtocol) Dispatch() error {
select {
case deterministicTaggingTargetBytes = <-p.PreviousNodeInPathChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <deterministicTaggingTargetBytes> (second round) on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <deterministicTaggingTargetBytes> (second round) on time.")
}

deterministicTaggingTarget := DeterministicTaggingMessage{Data: make([]libunlynx.CipherText, 0)}
Expand Down
2 changes: 1 addition & 1 deletion protocols/key_switching_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (p *KeySwitchingProtocol) announcementKSPhase() (kyber.Point, []kyber.Point
select {
case dataReferenceMessage = <-p.DownChannel:
case <-time.After(libunlynx.TIMEOUT):
return nil, nil, errors.New(p.ServerIdentity().String() + "didn't get the <dataReferenceMessage> on time.")
return nil, nil, errors.New(p.ServerIdentity().String() + " didn't get the <dataReferenceMessage> on time.")
}

if !p.IsLeaf() {
Expand Down
7 changes: 3 additions & 4 deletions protocols/shuffling+ddt_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package protocolsunlynx

import (
"errors"
"os"
"sync"
"time"

Expand Down Expand Up @@ -158,19 +157,19 @@ func (p *ShufflingPlusDDTProtocol) Dispatch() error {
select {
case shufflingPlusDDTBytesMessageLength = <-p.LengthNodeChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <shufflingPlusDDTBytesMessageLength> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <shufflingPlusDDTBytesMessageLength> on time.")
}

var tmp shufflingPlusDDTBytesStruct
select {
case tmp = <-p.PreviousNodeInPathChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <tmp> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <tmp> on time.")
}

readData := libunlynx.StartTimer(p.Name() + "_ShufflingPlusDDT(ReadData)")
sm := ShufflingPlusDDTMessage{}
err = sm.FromBytes(tmp.Data, tmp.ShuffKey, shufflingPlusDDTBytesMessageLength.CVLengths)
err := sm.FromBytes(tmp.Data, tmp.ShuffKey, shufflingPlusDDTBytesMessageLength.CVLengths)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions protocols/shuffling_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ func (p *ShufflingProtocol) Dispatch() error {
select {
case shufflingBytesMessageLength = <-p.LengthNodeChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <shufflingBytesMessageLength> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <shufflingBytesMessageLength> on time.")
}

var tmp shufflingBytesStruct
select {
case tmp = <-p.PreviousNodeInPathChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <tmp> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <tmp> on time.")
}

sm := ShufflingMessage{}
Expand Down
2 changes: 1 addition & 1 deletion protocols/utils/addrm_server_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (p *AddRmServerProtocol) Dispatch() error {
select {
case finalResultMessage = <-finalResultAddrm:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <finalResultMessage> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <finalResultMessage> on time.")
}

p.FeedbackChannel <- finalResultMessage
Expand Down
2 changes: 1 addition & 1 deletion protocols/utils/local_aggregation_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p *LocalAggregationProtocol) Dispatch() error {
select {
case finalResultMessage = <-finalResultAggr:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <finalResultMessage> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <finalResultMessage> on time.")
}

p.FeedbackChannel <- finalResultMessage
Expand Down
2 changes: 1 addition & 1 deletion protocols/utils/local_clear_aggregation_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (p *LocalClearAggregationProtocol) Dispatch() error {
select {
case finalResultMessage = <-finalResultClearAggr:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <finalResultMessage> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <finalResultMessage> on time.")
}

p.FeedbackChannel <- finalResultMessage
Expand Down
2 changes: 1 addition & 1 deletion protocols/utils/proofs_verification_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (p *ProofsVerificationProtocol) Dispatch() error {
select {
case finalResultMessage = <-finalResult:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(p.ServerIdentity().String() + "didn't get the <finalResultMessage> on time.")
return errors.New(p.ServerIdentity().String() + " didn't get the <finalResultMessage> on time.")
}

p.FeedbackChannel <- finalResultMessage
Expand Down
18 changes: 8 additions & 10 deletions services/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package servicesunlynx

import (
"errors"
"golang.org/x/xerrors"
"strconv"
"time"

Expand Down Expand Up @@ -416,13 +417,11 @@ func (s *Service) HandleQueryBroadcastFinished(recq *QueryBroadcastFinished) (ne

// NewProtocol creates a protocol instance executed by all nodes
func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfig) (onet.ProtocolInstance, error) {
err := tn.SetConfig(conf)
if err != nil {
return nil, err
if err := tn.SetConfig(conf); err != nil {
return nil, xerrors.Errorf("couldn't set config: %+v", err)
}

var pi onet.ProtocolInstance

target := SurveyID(string(conf.Data))
survey, err := s.getSurvey(SurveyID(conf.Data))
if err != nil {
Expand Down Expand Up @@ -580,7 +579,6 @@ func (s *Service) NewProtocol(tn *onet.TreeNodeInstance, conf *onet.GenericConfi
default:
return nil, errors.New("Service attempts to start an unknown protocol: " + tn.ProtocolName() + ".")
}

return pi, nil
}

Expand Down Expand Up @@ -733,7 +731,7 @@ func (s *Service) ShufflingPhase(targetSurvey SurveyID) error {
select {
case tmpShufflingResult = <-pi.(*protocolsunlynx.ShufflingProtocol).FeedbackChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(s.ServerIdentity().String() + "didn't get the <tmpShufflingResult> on time.")
return errors.New(s.ServerIdentity().String() + " didn't get the <tmpShufflingResult> on time.")
}

survey, err = s.getSurvey(targetSurvey)
Expand Down Expand Up @@ -768,7 +766,7 @@ func (s *Service) TaggingPhase(targetSurvey SurveyID) error {
select {
case tmpDeterministicTaggingResult = <-pi.(*protocolsunlynx.DeterministicTaggingProtocol).FeedbackChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(s.ServerIdentity().String() + "didn't get the <tmpDeterministicTaggingResult> on time.")
return errors.New(s.ServerIdentity().String() + " didn't get the <tmpDeterministicTaggingResult> on time.")
}

survey, err = s.getSurvey(targetSurvey)
Expand Down Expand Up @@ -807,7 +805,7 @@ func (s *Service) AggregationPhase(targetSurvey SurveyID) error {
select {
case cothorityAggregatedData = <-pi.(*protocolsunlynx.CollectiveAggregationProtocol).FeedbackChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(s.ServerIdentity().String() + "didn't get the <cothorityAggregatedData> on time.")
return errors.New(s.ServerIdentity().String() + " didn't get the <cothorityAggregatedData> on time.")
}

survey, err := s.getSurvey(targetSurvey)
Expand Down Expand Up @@ -836,7 +834,7 @@ func (s *Service) DROPhase(targetSurvey SurveyID) error {
select {
case tmpShufflingResult = <-pi.(*protocolsunlynx.ShufflingProtocol).FeedbackChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(s.ServerIdentity().String() + "didn't get the <tmpShufflingResult> on time.")
return errors.New(s.ServerIdentity().String() + " didn't get the <tmpShufflingResult> on time.")
}

shufflingResult := protocolsunlynx.MatrixCipherTextToProcessResponse(tmpShufflingResult, survey.Lengths)
Expand All @@ -862,7 +860,7 @@ func (s *Service) KeySwitchingPhase(targetSurvey SurveyID) error {
select {
case tmpKeySwitchedAggregatedResponses = <-pi.(*protocolsunlynx.KeySwitchingProtocol).FeedbackChannel:
case <-time.After(libunlynx.TIMEOUT):
return errors.New(s.ServerIdentity().String() + "didn't get the <tmpKeySwitchedAggregatedResponses> on time.")
return errors.New(s.ServerIdentity().String() + " didn't get the <tmpKeySwitchedAggregatedResponses> on time.")
}

keySwitchedAggregatedResponses := protocolsunlynx.CipherVectorToFilteredResponse(tmpKeySwitchedAggregatedResponses, survey.Lengths)
Expand Down

0 comments on commit 3a7f339

Please sign in to comment.