From b7b6003babcd0ce880efc40752a4c5614ae0fd39 Mon Sep 17 00:00:00 2001 From: hjpotter92 Date: Thu, 24 Aug 2023 22:59:59 +0530 Subject: [PATCH] revive: Fix go vet reported warnings --- cmd/devtool/devtool.go | 2 +- cmd/devtool/devtool/devtool_utils.go | 3 ++- cmd/livepeer/livepeer.go | 4 ++-- cmd/livepeer/starter/starter.go | 20 ++++++++++---------- cmd/livepeer_cli/wizard_bond.go | 2 +- cmd/livepeer_cli/wizard_rounds.go | 3 +-- cmd/livepeer_cli/wizard_stats.go | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/devtool/devtool.go b/cmd/devtool/devtool.go index 3343092e24..fad36cdb85 100644 --- a/cmd/devtool/devtool.go +++ b/cmd/devtool/devtool.go @@ -126,7 +126,7 @@ func main() { } createRunScript(devtool.EthController, dataDir, serviceHost, cfg) if !isBroadcaster { - cliPort += 1 + cliPort++ tDataDir := filepath.Join(*baseDataDir, "transcoder_"+acc) err = os.MkdirAll(tDataDir, 0755) if err != nil { diff --git a/cmd/devtool/devtool/devtool_utils.go b/cmd/devtool/devtool/devtool_utils.go index 89d1aa4da3..8576c403e8 100644 --- a/cmd/devtool/devtool/devtool_utils.go +++ b/cmd/devtool/devtool/devtool_utils.go @@ -319,7 +319,8 @@ func (d *Devtool) RegisterOrchestrator(cfg DevtoolConfig) error { tx, err = d.Client.Transcoder(eth.FromPerc(10), eth.FromPerc(5)) if err == eth.ErrCurrentRoundLocked { - // wait for next round and retry + // TODO: wait for next round and retry + fmt.Println("unimplemented: wait for next round and retry") } if err != nil { glog.Error(err) diff --git a/cmd/livepeer/livepeer.go b/cmd/livepeer/livepeer.go index 33e95575bf..a13ee9f598 100755 --- a/cmd/livepeer/livepeer.go +++ b/cmd/livepeer/livepeer.go @@ -34,7 +34,7 @@ func main() { flag.CommandLine.SetOutput(os.Stdout) // Help & Log - mistJson := flag.Bool("j", false, "Print application info as json") + mistJSON := flag.Bool("j", false, "Print application info as json") version := flag.Bool("version", false, "Print out the version") verbosity := flag.String("v", "3", "Log verbosity. {4|5|6}") @@ -53,7 +53,7 @@ func main() { vFlag.Value.Set(*verbosity) - if *mistJson { + if *mistJSON { mistconnector.PrintMistConfigJson( "livepeer", "Official implementation of the Livepeer video processing protocol. Can play all roles in the network.", diff --git a/cmd/livepeer/starter/starter.go b/cmd/livepeer/starter/starter.go index aa8c4176be..9b9fbc237b 100755 --- a/cmd/livepeer/starter/starter.go +++ b/cmd/livepeer/starter/starter.go @@ -58,8 +58,8 @@ var ( smTTL = 60 // 1 minute ) -const RtmpPort = "1935" -const RpcPort = "8935" +const RTMPPort = "1935" +const RPCPort = "8935" const CliPort = "7935" type LivepeerConfig struct { @@ -134,7 +134,7 @@ type LivepeerConfig struct { func DefaultLivepeerConfig() LivepeerConfig { // Network & Addresses: defaultNetwork := "offchain" - defaultRtmpAddr := "127.0.0.1:" + RtmpPort + defaultRtmpAddr := "127.0.0.1:" + RTMPPort defaultCliAddr := "127.0.0.1:" + CliPort defaultHttpAddr := "" defaultServiceAddr := "" @@ -769,7 +769,7 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) { var sm pm.SenderMonitor if *cfg.RedeemerAddr != "" { - *cfg.RedeemerAddr = defaultAddr(*cfg.RedeemerAddr, "127.0.0.1", RpcPort) + *cfg.RedeemerAddr = defaultAddr(*cfg.RedeemerAddr, "127.0.0.1", RPCPort) rc, err := server.NewRedeemerClient(*cfg.RedeemerAddr, senderWatcher, timeWatcher) if err != nil { glog.Error("Unable to start redeemer client: ", err) @@ -865,7 +865,7 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) { return } - *cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "127.0.0.1", RpcPort) + *cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "127.0.0.1", RPCPort) url, err := url.ParseRequestURI("https://" + *cfg.HttpAddr) if err != nil { glog.Error("Could not parse redeemer URI: ", err) @@ -1008,8 +1008,8 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) { if n.NodeType == core.BroadcasterNode { // default lpms listener for broadcaster; same as default rpc port // TODO provide an option to disable this? - *cfg.RtmpAddr = defaultAddr(*cfg.RtmpAddr, "127.0.0.1", RtmpPort) - *cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "127.0.0.1", RpcPort) + *cfg.RtmpAddr = defaultAddr(*cfg.RtmpAddr, "127.0.0.1", RTMPPort) + *cfg.HttpAddr = defaultAddr(*cfg.HttpAddr, "127.0.0.1", RPCPort) bcast := core.NewBroadcaster(n) @@ -1244,7 +1244,7 @@ func parseOrchAddrs(addrs string) []*url.URL { if len(addrs) > 0 { for _, addr := range strings.Split(addrs, ",") { addr = strings.TrimSpace(addr) - addr = defaultAddr(addr, "127.0.0.1", RpcPort) + addr = defaultAddr(addr, "127.0.0.1", RPCPort) if !strings.HasPrefix(addr, "http") { addr = "https://" + addr } @@ -1320,7 +1320,7 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) { glog.Errorf("Could not look up public IP err=%q", err) return nil, err } - addr := "https://" + strings.TrimSpace(string(body)) + ":" + RpcPort + addr := "https://" + strings.TrimSpace(string(body)) + ":" + RPCPort inferredUri, err := url.ParseRequestURI(addr) if err != nil { glog.Errorf("Could not look up public IP err=%q", err) @@ -1340,7 +1340,7 @@ func getServiceURI(n *core.LivepeerNode, serviceAddr string) (*url.URL, error) { ethUri, err := url.ParseRequestURI(addr) if err != nil { glog.Errorf("Could not parse service URI; orchestrator may be unreachable err=%q", err) - ethUri, _ = url.ParseRequestURI("http://127.0.0.1:" + RpcPort) + ethUri, _ = url.ParseRequestURI("http://127.0.0.1:" + RPCPort) } if ethUri.Hostname() != inferredUri.Hostname() || ethUri.Port() != inferredUri.Port() { glog.Errorf("Service address %v did not match discovered address %v; set the correct address in livepeer_cli or use -serviceAddr", ethUri, inferredUri) diff --git a/cmd/livepeer_cli/wizard_bond.go b/cmd/livepeer_cli/wizard_bond.go index 572d1479c7..3086112028 100644 --- a/cmd/livepeer_cli/wizard_bond.go +++ b/cmd/livepeer_cli/wizard_bond.go @@ -64,7 +64,7 @@ func (w *wizard) getRegisteredOrchestrators() ([]lpTypes.Transcoder, error) { } if resp.StatusCode != http.StatusOK { - return nil, errors.New(fmt.Sprintf("http error: %d", resp.StatusCode)) + return nil, fmt.Errorf("http error: %d", resp.StatusCode) } defer resp.Body.Close() diff --git a/cmd/livepeer_cli/wizard_rounds.go b/cmd/livepeer_cli/wizard_rounds.go index a0ee9a1c68..36a87b4046 100644 --- a/cmd/livepeer_cli/wizard_rounds.go +++ b/cmd/livepeer_cli/wizard_rounds.go @@ -1,7 +1,6 @@ package main import ( - "errors" "fmt" "io/ioutil" "math/big" @@ -17,7 +16,7 @@ func (w *wizard) currentRound() (*big.Int, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return nil, errors.New(fmt.Sprintf("http response status %d", resp.StatusCode)) + return nil, fmt.Errorf("http response status %d", resp.StatusCode) } body, err := ioutil.ReadAll(resp.Body) diff --git a/cmd/livepeer_cli/wizard_stats.go b/cmd/livepeer_cli/wizard_stats.go index 85c63864a6..5034c11b25 100644 --- a/cmd/livepeer_cli/wizard_stats.go +++ b/cmd/livepeer_cli/wizard_stats.go @@ -302,7 +302,7 @@ func (w *wizard) getProtocolParameters() (lpTypes.ProtocolParameters, error) { } if resp.StatusCode != http.StatusOK { - return lpTypes.ProtocolParameters{}, errors.New(fmt.Sprintf("http error: %d", resp.StatusCode)) + return lpTypes.ProtocolParameters{}, fmt.Errorf("http error: %d", resp.StatusCode) } defer resp.Body.Close() @@ -328,7 +328,7 @@ func (w *wizard) getContractAddresses() (map[string]common.Address, error) { } if resp.StatusCode != http.StatusOK { - return nil, errors.New(fmt.Sprintf("http error: %d", resp.StatusCode)) + return nil, fmt.Errorf("http error: %d", resp.StatusCode) } defer resp.Body.Close() @@ -465,7 +465,7 @@ func (w *wizard) currentBlock() (*big.Int, error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return nil, errors.New(fmt.Sprintf("http response status %d", resp.StatusCode)) + return nil, fmt.Errorf("http response status %d", resp.StatusCode) } body, err := ioutil.ReadAll(resp.Body)