@@ -45,11 +45,7 @@ and output the result. The requests are one or more string arguments.
4545If no string argument is given, requests are constructed from standard input, where
4646each line is passed to a separate request.` ,
4747 RunE : func (cmd * cobra.Command , args []string ) error {
48- _ , err := requests (args )
49- if err != nil {
50- return err
51- }
52- return nil
48+ return requests (args )
5349 },
5450}
5551
@@ -85,25 +81,25 @@ func request(client client.Client, arg string) {
8581 }
8682}
8783
88- func requests (args []string ) ([] byte , error ) {
84+ func requests (args []string ) error {
8985 id := uint32 (viper .GetInt ("client.id" ))
9086
9187 keysFile , err := os .Open (viper .GetString ("keys" ))
9288 if err != nil {
93- return nil , fmt .Errorf ("failed to open keyset file: %s" , err )
89+ return fmt .Errorf ("failed to open keyset file: %s" , err )
9490 }
9591
9692 auth , err := authen .New ([]api.AuthenticationRole {api .ClientAuthen }, id , keysFile )
9793 if err != nil {
98- return nil , fmt .Errorf ("failed to create authenticator: %s" , err )
94+ return fmt .Errorf ("failed to create authenticator: %s" , err )
9995 }
10096
10197 cfg := config .New ()
10298 cfg .LoadConfig (viper .GetString ("consensusConf" ))
10399
104100 loggingOpts , err := getLoggingOptions ()
105101 if err != nil {
106- return nil , fmt .Errorf ("failed to create logging options: %s" , err )
102+ return fmt .Errorf ("failed to create logging options: %s" , err )
107103 }
108104 clientLogger := logger .NewClientLogger (id , loggingOpts ... )
109105 clientOptions := client .WithLogger (clientLogger )
@@ -119,12 +115,12 @@ func requests(args []string) ([]byte, error) {
119115 // grpc.WithInsecure() option is passed here for simplicity.
120116 err = connector .ConnectManyReplicas (conn , peerAddrs , grpc .WithInsecure ())
121117 if err != nil {
122- return nil , fmt .Errorf ("failed to connect to peers: %s" , err )
118+ return fmt .Errorf ("failed to connect to peers: %s" , err )
123119 }
124120
125121 client , err := client .New (id , cfg .N (), cfg .F (), clientStack {auth , conn }, clientOptions )
126122 if err != nil {
127- return nil , fmt .Errorf ("failed to create client instance: %s" , err )
123+ return fmt .Errorf ("failed to create client instance: %s" , err )
128124 }
129125
130126 if len (args ) > 0 {
@@ -138,5 +134,5 @@ func requests(args []string) ([]byte, error) {
138134 }
139135 }
140136
141- return nil , nil
137+ return nil
142138}
0 commit comments