Skip to content
Snippets Groups Projects
Commit 58d33875 authored by Jonah Husson's avatar Jonah Husson
Browse files

Fixes for command line flags

parent af37bc6c
Branches
Tags
6 merge requests!510Release,!229Make the payload returned by NewSizedBroadcast include the extra padding so...,!221Xx 3891/symmetric integration,!218Xx 3891/symmetric integration,!217Add asymmetric client,!207WIP: Client Restructure
...@@ -1040,9 +1040,9 @@ func init() { ...@@ -1040,9 +1040,9 @@ func init() {
"Ensure successful message sending by checking for round completion") "Ensure successful message sending by checking for round completion")
viper.BindPFlag("verify-sends", rootCmd.Flags().Lookup("verify-sends")) 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") "", 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, rootCmd.PersistentFlags().UintP("waitTimeout", "", 15,
"The number of seconds to wait for messages to arrive") "The number of seconds to wait for messages to arrive")
viper.BindPFlag("waitTimeout", viper.BindPFlag("waitTimeout",
......
...@@ -140,18 +140,18 @@ var symmetricCmd = &cobra.Command{ ...@@ -140,18 +140,18 @@ var symmetricCmd = &cobra.Command{
if message != "" { if message != "" {
broadcastMessage, err := broadcast.NewSizedBroadcast(scl.MaxPayloadSize(), []byte(message)) broadcastMessage, err := broadcast.NewSizedBroadcast(scl.MaxPayloadSize(), []byte(message))
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to create sized broadcast: %+v", err)
} }
rid, eid, err := scl.Broadcast(broadcastMessage, cmix.GetDefaultCMIXParams()) rid, eid, err := scl.Broadcast(broadcastMessage, cmix.GetDefaultCMIXParams())
if err != nil { 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) jww.INFO.Printf("Sent symmetric broadcast message to %s over round %d", eid, rid)
} }
// Receive messages over the channel // Receive messages over the channel
expectedCnt := viper.GetUint("receiveCount")
waitSecs := viper.GetUint("waitTimeout") waitSecs := viper.GetUint("waitTimeout")
expectedCnt := viper.GetUint("receiveCount")
waitTimeout := time.Duration(waitSecs) * time.Second waitTimeout := time.Duration(waitSecs) * time.Second
receivedCount := uint(0) receivedCount := uint(0)
done := false done := false
...@@ -165,7 +165,7 @@ var symmetricCmd = &cobra.Command{ ...@@ -165,7 +165,7 @@ var symmetricCmd = &cobra.Command{
jww.ERROR.Printf("Failed to decode sized broadcast: %+v", err) jww.ERROR.Printf("Failed to decode sized broadcast: %+v", err)
continue 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 { if receivedCount == expectedCnt {
done = true done = true
} }
...@@ -177,6 +177,7 @@ var symmetricCmd = &cobra.Command{ ...@@ -177,6 +177,7 @@ var symmetricCmd = &cobra.Command{
} }
jww.INFO.Printf("Received %d/%d Messages!", receivedCount, expectedCnt) jww.INFO.Printf("Received %d/%d Messages!", receivedCount, expectedCnt)
scl.Stop()
err = client.StopNetworkFollower() err = client.StopNetworkFollower()
if err != nil { if err != nil {
jww.WARN.Printf( jww.WARN.Printf(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment