diff --git a/api/utilsInterfaces_test.go b/api/utilsInterfaces_test.go index 730f7a242a93cd0027bb6713dcbc8ac6c2bd2a7e..380a691a4b21e23534b28a836ca8c30cf475afdf 100644 --- a/api/utilsInterfaces_test.go +++ b/api/utilsInterfaces_test.go @@ -101,11 +101,10 @@ func (t *testNetworkManagerGeneric) CheckGarbledMessages() { return } -func (t *testNetworkManagerGeneric) GetVerboseRounds()string{ +func (t *testNetworkManagerGeneric) GetVerboseRounds() string { return "" } - func (t *testNetworkManagerGeneric) SendE2E(message.Send, params.E2E, *stoppable.Single) ( []id.Round, cE2e.MessageID, time.Time, error) { rounds := []id.Round{id.Round(0), id.Round(1), id.Round(2)} diff --git a/api/version_vars.go b/api/version_vars.go index 543710098c8c89acb4888c9471b97ca02a1670e9..a623d244dcc2f3432178bdaad7228de94152763b 100644 --- a/api/version_vars.go +++ b/api/version_vars.go @@ -1,9 +1,9 @@ // Code generated by go generate; DO NOT EDIT. // This file was generated by robots at -// 2021-10-04 13:38:28.823704 -0500 CDT m=+0.043527743 +// 2021-10-05 11:00:55.470586 -0500 CDT m=+0.027257685 package api -const GITVERSION = `7784b3dc add bindings for enabling grpc logs` +const GITVERSION = `a0d7f372 add bindings for enabling grpc logs` const SEMVER = "2.9.0" const DEPENDENCIES = `module gitlab.com/elixxir/client @@ -28,7 +28,7 @@ require ( gitlab.com/elixxir/crypto v0.0.7-0.20210920180151-6c9b84bae372 gitlab.com/elixxir/ekv v0.1.5 gitlab.com/elixxir/primitives v0.0.3-0.20210920180121-b85bca5212f4 - gitlab.com/xx_network/comms v0.0.4-0.20210921011654-3b73a40ed3d6 + gitlab.com/xx_network/comms v0.0.4-0.20211005155924-3659069a608a gitlab.com/xx_network/crypto v0.0.5-0.20210920180047-4dd4aed4a942 gitlab.com/xx_network/primitives v0.0.4-0.20210915220237-70cb4551d6f3 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 diff --git a/cmd/root.go b/cmd/root.go index 1c60c63b1bfdd5fb155ce44ef5cdb0db8057f8b8..0b1028f1a9ecf0f7a49b635f0f6287039549564d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -247,7 +247,7 @@ var rootCmd = &cobra.Command{ } } fmt.Printf("Received %d\n", receiveCnt) - if roundsNotepad!=nil{ + if roundsNotepad != nil { roundsNotepad.INFO.Printf("\n%s", client.GetNetworkInterface().GetVerboseRounds()) } @@ -679,7 +679,7 @@ func initLog(threshold uint, logPath string) { jww.SetLogThreshold(jww.LevelInfo) } - if viper.GetBool("verboseRoundTracking"){ + if viper.GetBool("verboseRoundTracking") { initRoundLog(logPath) } } @@ -734,8 +734,8 @@ func init() { viper.BindPFlag("logLevel", rootCmd.PersistentFlags().Lookup("logLevel")) rootCmd.PersistentFlags().Bool("verboseRoundTracking", false, - "Verbose round tracking, keeps track and prints all rounds the " + - "client was aware of while running. Defaults to false if not set.") + "Verbose round tracking, keeps track and prints all rounds the "+ + "client was aware of while running. Defaults to false if not set.") viper.BindPFlag("verboseRoundTracking", rootCmd.PersistentFlags().Lookup("verboseRoundTracking")) rootCmd.PersistentFlags().StringP("session", "s", diff --git a/go.mod b/go.mod index 8e0f3c44c00e9403b652083810ef060ef3560f29..fd088f4c56860d9e955895953a6061f5ab92888f 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( gitlab.com/elixxir/crypto v0.0.7-0.20210920180151-6c9b84bae372 gitlab.com/elixxir/ekv v0.1.5 gitlab.com/elixxir/primitives v0.0.3-0.20210920180121-b85bca5212f4 - gitlab.com/xx_network/comms v0.0.4-0.20210921011654-3b73a40ed3d6 + gitlab.com/xx_network/comms v0.0.4-0.20211005155924-3659069a608a gitlab.com/xx_network/crypto v0.0.5-0.20210920180047-4dd4aed4a942 gitlab.com/xx_network/primitives v0.0.4-0.20210915220237-70cb4551d6f3 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 diff --git a/go.sum b/go.sum index bde20519de0e3d2cc72cdc0a8bee2f5bf587ea12..793af2493d789b1381bdd6a40a4e9ca8456e4d39 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,9 @@ gitlab.com/elixxir/primitives v0.0.1/go.mod h1:kNp47yPqja2lHSiS4DddTvFpB/4D9dB2Y gitlab.com/elixxir/primitives v0.0.3-0.20210920180121-b85bca5212f4 h1:mCJp3JkhqW+WSdd2gxP64FyO+d9ON8XOMmiO1yDaZ14= gitlab.com/elixxir/primitives v0.0.3-0.20210920180121-b85bca5212f4/go.mod h1:mZ/7v6njF+mUGUs83z6tybcGs+GuxpEVPY/lrNLrRqc= gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= -gitlab.com/xx_network/comms v0.0.4-0.20210921011654-3b73a40ed3d6 h1:dYaM0O3vMTFLo5Oq4D1lzi3VdTpfNy2W0oe8Dz12pxY= gitlab.com/xx_network/comms v0.0.4-0.20210921011654-3b73a40ed3d6/go.mod h1:5K8m1XBzIMWodR4BqGydP+9RyyVJ9e/yjmfyEyeju14= +gitlab.com/xx_network/comms v0.0.4-0.20211005155924-3659069a608a h1:tArQsPqN5GZuQSTiDjBSIANWvN75IN2gTgR0qa76TTg= +gitlab.com/xx_network/comms v0.0.4-0.20211005155924-3659069a608a/go.mod h1:5K8m1XBzIMWodR4BqGydP+9RyyVJ9e/yjmfyEyeju14= gitlab.com/xx_network/crypto v0.0.3/go.mod h1:DF2HYvvCw9wkBybXcXAgQMzX+MiGbFPjwt3t17VRqRE= gitlab.com/xx_network/crypto v0.0.4/go.mod h1:+lcQEy+Th4eswFgQDwT0EXKp4AXrlubxalwQFH5O0Mk= gitlab.com/xx_network/crypto v0.0.5-0.20210920180047-4dd4aed4a942 h1:pOFwTWCdaFhwve2aWoqicqQIECuZ1mIUeLtVMUAauEg= diff --git a/groupChat/utils_test.go b/groupChat/utils_test.go index 9fc0fd6aab4babfba1ea9c26285abbfd15df3d98..d43ada0dc827fcff5fe253d9d89189abf588f778 100644 --- a/groupChat/utils_test.go +++ b/groupChat/utils_test.go @@ -261,7 +261,7 @@ func (tnm *testNetworkManager) SendUnsafe(message.Send, params.Unsafe) ([]id.Rou return []id.Round{}, nil } -func (tnm *testNetworkManager) GetVerboseRounds()string{ +func (tnm *testNetworkManager) GetVerboseRounds() string { return "" } diff --git a/network/follow.go b/network/follow.go index 8a66fc30f6dba4f9e22133138dad223f192a713f..9dcc4085a3a4097c96fac8688923330b31df32cd 100644 --- a/network/follow.go +++ b/network/follow.go @@ -296,7 +296,7 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, // handling threads roundChecker := func(rid id.Round) bool { hasMessage := rounds.Checker(rid, filterList, identity.CR) - if !hasMessage && m.verboseRounds != nil{ + if !hasMessage && m.verboseRounds != nil { m.verboseRounds.denote(rid, RoundState(NoMessageAvailable)) } return hasMessage @@ -307,9 +307,9 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, earliestTrackedRound := id.Round(pollResp.EarliestRound) updated, old, _ := identity.ER.Set(earliestTrackedRound) if old == 0 { - if gwRoundsState.GetLastChecked()> id.Round(m.param.KnownRoundsThreshold){ + if gwRoundsState.GetLastChecked() > id.Round(m.param.KnownRoundsThreshold) { updated = gwRoundsState.GetLastChecked() - id.Round(m.param.KnownRoundsThreshold) - }else{ + } else { updated = 1 } identity.ER.Set(updated) @@ -354,8 +354,8 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, if m.verboseRounds != nil { trackingStart := updated - if uint(earliestRemaining-updated)>m.param.KnownRoundsThreshold{ - trackingStart = earliestRemaining-id.Round(m.param.KnownRoundsThreshold) + if uint(earliestRemaining-updated) > m.param.KnownRoundsThreshold { + trackingStart = earliestRemaining - id.Round(m.param.KnownRoundsThreshold) } jww.DEBUG.Printf("Rounds tracked: %v to %v", trackingStart, earliestRemaining) for i := trackingStart; i <= earliestRemaining; i++ { diff --git a/network/gateway/hostPool.go b/network/gateway/hostPool.go index a4d7e3390b140abf040b67f833794c868f717ddf..2609c4731869d0f3bce85c392a90a07a61a30e91 100644 --- a/network/gateway/hostPool.go +++ b/network/gateway/hostPool.go @@ -143,6 +143,9 @@ func newHostPool(poolParams PoolParams, rng *fastRNG.StreamGenerator, jww.WARN.Printf("Unable to add stored host %s: %s", hid, err.Error()) } else { numHostsAdded++ + if numHostsAdded >= len(result.hostList) { + break + } } } } else { @@ -347,7 +350,7 @@ func (h *HostPool) replaceHost(newId *id.ID, oldPoolIndex uint32) error { return err } - // Convert list of of non-nil and non-zero hosts to ID list + // Convert list of non-nil and non-zero hosts to ID list idList := make([]*id.ID, 0, len(h.hostList)) for _, host := range h.hostList { if host.GetId() != nil && !host.GetId().Cmp(&id.ID{}) { @@ -360,7 +363,7 @@ func (h *HostPool) replaceHost(newId *id.ID, oldPoolIndex uint32) error { } // replaceHostNoStore replaces the given slot in the HostPool with a new Gateway -// with the specified ID. +// with the specified ID without saving changes to storage func (h *HostPool) replaceHostNoStore(newId *id.ID, oldPoolIndex uint32) error { // Obtain that GwId's Host object newHost, ok := h.manager.GetHost(newId) diff --git a/network/gateway/sender.go b/network/gateway/sender.go index 704516310181d69d840cc2a379d1708d5dd64248..30651bba1f0f9af495ba4d881a4dd2d4e9021252 100644 --- a/network/gateway/sender.go +++ b/network/gateway/sender.go @@ -47,24 +47,24 @@ func (s *Sender) SendToAny(sendFunc func(host *connect.Host) (interface{}, error result, err := sendFunc(proxies[proxy]) if stop != nil && !stop.IsRunning() { return nil, errors.Errorf(stoppable.ErrMsg, stop.Name(), "SendToAny") - }else if err==nil{ + } else if err == nil { return result, nil } else if strings.Contains(err.Error(), RetryableError) { // Retry of the proxy could not communicate jww.INFO.Printf("Unable to SendToAny via %s: non-fatal error received, retrying: %s", proxies[proxy].GetId().String(), err) - }else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), "unable to connect to target host") { - }else if replaced, checkReplaceErr := s.checkReplace(proxies[proxy].GetId(), err); replaced{ - if checkReplaceErr!=nil{ + } else if replaced, checkReplaceErr := s.checkReplace(proxies[proxy].GetId(), err); replaced { + if checkReplaceErr != nil { jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s with error %s", proxies[proxy].GetId().String(), checkReplaceErr) - }else{ + } else { jww.WARN.Printf("Unable to SendToAny, replaced a proxy %s", proxies[proxy].GetId().String()) } - }else{ - return nil, errors.WithMessage(err,"Received error with SendToAny") + } else { + return nil, errors.WithMessage(err, "Received error with SendToAny") } } @@ -90,19 +90,19 @@ func (s *Sender) SendToPreferred(targets []*id.ID, // Retry of the proxy could not communicate jww.INFO.Printf("Unable to to SendToPreferred first pass %s via %s: non-fatal error received, retrying: %s", targets[i], targetHosts[i].GetId(), err) - }else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), "unable to connect to target host") { // Retry of the proxy could not communicate - jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, " + + jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s: %s, "+ "proxy could not contact requested host", targets[i], targetHosts[i].GetId(), err) continue } else if replaced, checkReplaceErr := s.checkReplace(targetHosts[i].GetId(), err); replaced { - if checkReplaceErr!=nil{ - jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, " + + if checkReplaceErr != nil { + jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, "+ "proxy failed, was replaced with error: %s", targets[i], targetHosts[i].GetId(), checkReplaceErr) - }else{ - jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, " + + } else { + jww.WARN.Printf("Unable to SendToPreferred first pass %s via %s, "+ "proxy failed, was replaced", targets[i], targetHosts[i].GetId()) } @@ -153,19 +153,19 @@ func (s *Sender) SendToPreferred(targets []*id.ID, // Retry of the proxy could not communicate jww.INFO.Printf("Unable to SendToPreferred second pass %s via %s: non-fatal error received, retrying: %s", target, proxy, err) - }else if strings.Contains(err.Error(),"unable to connect to target host") { + } else if strings.Contains(err.Error(), "unable to connect to target host") { // Retry of the proxy could not communicate - jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s," + + jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s: %s,"+ " proxy could not contact requested host", target, proxy, err) continue } else if replaced, checkReplaceErr := s.checkReplace(proxy.GetId(), err); replaced { - if checkReplaceErr!=nil{ - jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s," + + if checkReplaceErr != nil { + jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s,"+ "proxy failed, was replaced with error: %s", target, proxy.GetId(), checkReplaceErr) - }else{ - jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s, " + + } else { + jww.WARN.Printf("Unable to SendToPreferred second pass %s via %s, "+ "proxy failed, was replaced", target, proxy.GetId()) } @@ -180,4 +180,4 @@ func (s *Sender) SendToPreferred(targets []*id.ID, } return nil, errors.Errorf("Unable to send to any preferred") -} \ No newline at end of file +} diff --git a/network/manager.go b/network/manager.go index 5a4fbc76b0d08619a2b07afd16ed3f5d46838cd1..831d303d81c29df748a5a3be7680387770e8cef7 100644 --- a/network/manager.go +++ b/network/manager.go @@ -234,7 +234,7 @@ func (m *manager) SetPoolFilter(f gateway.Filter) { // GetVerboseRounds returns verbose round information func (m *manager) GetVerboseRounds() string { - if m.verboseRounds==nil{ + if m.verboseRounds == nil { return "Verbose Round tracking not enabled" } return m.verboseRounds.String() diff --git a/network/node/register.go b/network/node/register.go index 6ad601a0b9d9d984b3c1aebd41c4235258888b01..914fb90133ddd6ed558aaf5cfe1157d6e566cd01 100644 --- a/network/node/register.go +++ b/network/node/register.go @@ -78,8 +78,8 @@ func registerNodes(sender *gateway.Sender, session *storage.Session, stop.ToStopped() return case gw := <-c: - nidStr := fmt.Sprintf("%x",gw.Node.ID) - if _, operating := inProgress.LoadOrStore(nidStr,struct{}{}); operating{ + nidStr := fmt.Sprintf("%x", gw.Node.ID) + if _, operating := inProgress.LoadOrStore(nidStr, struct{}{}); operating { continue } err := registerWithNode(sender, comms, gw, regSignature, @@ -202,10 +202,10 @@ func requestNonce(sender *gateway.Sender, comms RegisterNodeCommsInterface, gwId TimeStamp: registrationTimestampNano, }) if err != nil { - return nil, errors.WithMessage(err,"Register: Failed requesting nonce from gateway") + return nil, errors.WithMessage(err, "Register: Failed requesting nonce from gateway") } if nonceResponse.Error != "" { - return nil, errors.WithMessage(err,"requestNonce: nonceResponse error") + return nil, errors.WithMessage(err, "requestNonce: nonceResponse error") } return nonceResponse, nil }, stop) diff --git a/network/rounds/retrieve.go b/network/rounds/retrieve.go index cf1584a8d753b063e9b128dfcb15848ac5080bc0..9559e51b573757dccabc7f962cbb115809adb129 100644 --- a/network/rounds/retrieve.go +++ b/network/rounds/retrieve.go @@ -159,7 +159,7 @@ func (m *Manager) getMessagesFromGateway(roundID id.Round, msgResp, err := comms.RequestMessages(host, msgReq) if err == nil && !msgResp.GetHasRound() { errRtn := errors.Errorf(noRoundError, roundID) - return message.Bundle{}, errors.WithMessage(errRtn,gateway.RetryableError) + return message.Bundle{}, errors.WithMessage(errRtn, gateway.RetryableError) } return msgResp, err diff --git a/single/manager_test.go b/single/manager_test.go index 9657e47b4b9dd1030156eb15e5250184d64d3579..d39febc07a41154f3cb164af1b4755325bcef332 100644 --- a/single/manager_test.go +++ b/single/manager_test.go @@ -287,7 +287,7 @@ func (tnm *testNetworkManager) SendE2E(message.Send, params.E2E, *stoppable.Sing return nil, e2e.MessageID{}, time.Time{}, nil } -func (tnm *testNetworkManager) GetVerboseRounds()string{ +func (tnm *testNetworkManager) GetVerboseRounds() string { return "" } diff --git a/single/receiveResponse.go b/single/receiveResponse.go index ceb6e79e51e4fc60991179c32623d31208e98e6d..8f09d8c8d7a98ff142eddaaef40e0bc5bd0a3369 100644 --- a/single/receiveResponse.go +++ b/single/receiveResponse.go @@ -41,9 +41,9 @@ func (m *Manager) receiveResponseHandler(rawMessages chan message.Receive, if err != nil { em := fmt.Sprintf("Failed to read single-use "+ "CMIX message response: %+v", err) - if strings.Contains(err.Error(), "no state exists for the reception ID"){ + if strings.Contains(err.Error(), "no state exists for the reception ID") { jww.TRACE.Print(em) - }else{ + } else { if m.client != nil { m.client.ReportEvent(9, "SingleUse", "Error", em)