From 2d6f7faf8f8f2740b1ff4032157f04e7b800992b Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Fri, 2 Oct 2020 19:53:59 +0000 Subject: [PATCH] Minor cleanup --- api/client.go | 6 ------ api/send.go | 3 ++- cmd/root.go | 8 ++++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/api/client.go b/api/client.go index da77598e3..da8603198 100644 --- a/api/client.go +++ b/api/client.go @@ -356,12 +356,6 @@ func parseNDF(ndfString string) (*ndf.NetworkDefinition, error) { return ndf, nil } -func (c *Client) getCMIXPrimeSize() int { - ndf := c.network.GetInstance().GetPartialNdf().Get() - cmixGrp, _ := decodeGroups(ndf) - return len(cmixGrp.GetPBytes()) -} - // decodeGroups returns the e2e and cmix groups from the ndf func decodeGroups(ndf *ndf.NetworkDefinition) (cmixGrp, e2eGrp *cyclic.Group) { largeIntBits := 16 diff --git a/api/send.go b/api/send.go index 670525548..a83862dd9 100644 --- a/api/send.go +++ b/api/send.go @@ -46,7 +46,8 @@ func (c *Client) SendCMIX(msg format.Message, param params.CMIX) (id.Round, // FIXME: this is weird and shouldn't be necessary, but it is. func (c *Client) NewCMIXMessage(recipient *id.ID, contents []byte) format.Message { - msg := format.NewMessage(c.getCMIXPrimeSize()) + primeSize := len(c.storage.Cmix().GetGroup().GetPBytes()) + msg := format.NewMessage(primeSize) msg.SetContents(contents) msg.SetRecipientID(recipient) return msg diff --git a/cmd/root.go b/cmd/root.go index e283842b3..df02bc009 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -163,7 +163,7 @@ var rootCmd = &cobra.Command{ connected := make(chan bool, 1) client.GetHealth().AddChannel(connected) waitTimeout := time.Duration(viper.GetUint("waitTimeout")) - timeoutTick := time.NewTicker(waitTimeout * time.Second) + timeoutTimer := time.NewTimer(waitTimeout * time.Second) isConnected := false for !isConnected { select { @@ -171,7 +171,7 @@ var rootCmd = &cobra.Command{ jww.INFO.Printf("health status: %v\n", isConnected) break - case <-timeoutTick.C: + case <-timeoutTimer.C: jww.FATAL.Panic("timeout on connection") } } @@ -198,11 +198,11 @@ var rootCmd = &cobra.Command{ // Wait until message timeout or we receive enough then exit // TODO: Actually check for how many messages we've received receiveCnt := viper.GetUint("receiveCount") - timeoutTick = time.NewTicker(waitTimeout * time.Second) + timeoutTimer = time.NewTimer(waitTimeout * time.Second) done := false for !done { select { - case <-timeoutTick.C: + case <-timeoutTimer.C: fmt.Println("Timed out!") done = true break -- GitLab