diff --git a/api/client.go b/api/client.go index da77598e367a878dc87729974e2e7a70c4d1f664..da8603198def8b98bd217b8e7ccfc4543eb9815a 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 67052554846c88ae7215f27c81fdb51975a18514..a83862dd9f73df28a663e4655aedcbb8d2961ac6 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 e283842b3b740ce5732f99c2a6313a4f25c14c72..df02bc00954d7ec5a67d6790c78d9647a983f3dc 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