From 58d338758ff42d3130ad714df84de0cb6ed3678e Mon Sep 17 00:00:00 2001 From: jbhusson <jonah@elixxir.io> Date: Thu, 5 May 2022 15:37:41 -0400 Subject: [PATCH] Fixes for command line flags --- cmd/root.go | 4 ++-- cmd/symmetric.go | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 1d6d3c922..5d9cd1000 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1040,9 +1040,9 @@ func init() { "Ensure successful message sending by checking for round completion") viper.BindPFlag("verify-sends", rootCmd.Flags().Lookup("verify-sends")) - rootCmd.Flags().UintP("receiveCount", + rootCmd.PersistentFlags().UintP("receiveCount", "", 1, "How many messages we should wait for before quitting") - viper.BindPFlag("receiveCount", rootCmd.Flags().Lookup("receiveCount")) + viper.BindPFlag("receiveCount", rootCmd.PersistentFlags().Lookup("receiveCount")) rootCmd.PersistentFlags().UintP("waitTimeout", "", 15, "The number of seconds to wait for messages to arrive") viper.BindPFlag("waitTimeout", diff --git a/cmd/symmetric.go b/cmd/symmetric.go index e61b87195..20505235b 100644 --- a/cmd/symmetric.go +++ b/cmd/symmetric.go @@ -140,18 +140,18 @@ var symmetricCmd = &cobra.Command{ if message != "" { broadcastMessage, err := broadcast.NewSizedBroadcast(scl.MaxPayloadSize(), []byte(message)) if err != nil { - + jww.ERROR.Printf("Failed to create sized broadcast: %+v", err) } rid, eid, err := scl.Broadcast(broadcastMessage, cmix.GetDefaultCMIXParams()) if err != nil { - jww.ERROR.Printf("Failed to send symmentric broadcast message: %+v", err) + jww.ERROR.Printf("Failed to send symmetric broadcast message: %+v", err) } jww.INFO.Printf("Sent symmetric broadcast message to %s over round %d", eid, rid) } // Receive messages over the channel - expectedCnt := viper.GetUint("receiveCount") waitSecs := viper.GetUint("waitTimeout") + expectedCnt := viper.GetUint("receiveCount") waitTimeout := time.Duration(waitSecs) * time.Second receivedCount := uint(0) done := false @@ -165,7 +165,7 @@ var symmetricCmd = &cobra.Command{ jww.ERROR.Printf("Failed to decode sized broadcast: %+v", err) continue } - fmt.Printf("Symmetric broadcast message received: %s\n", string(receivedBroadcast)) + fmt.Printf("Symmetric broadcast message %d/%d received: %s\n", receivedCount, expectedCnt, string(receivedBroadcast)) if receivedCount == expectedCnt { done = true } @@ -177,6 +177,7 @@ var symmetricCmd = &cobra.Command{ } jww.INFO.Printf("Received %d/%d Messages!", receivedCount, expectedCnt) + scl.Stop() err = client.StopNetworkFollower() if err != nil { jww.WARN.Printf( -- GitLab