Skip to content

Commit

Permalink
Various minor linter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jclapis committed May 7, 2024
1 parent 1fb5c25 commit c6452ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions beacon/client/std-http-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ func (c *StandardHttpClient) getFinalityCheckpoints(ctx context.Context, stateId
}

// Get fork
/*
func (c *StandardHttpClient) getFork(ctx context.Context, stateId string) (ForkResponse, error) {
responseBody, status, err := c.getRequest(ctx, fmt.Sprintf(RequestForkPath, stateId))
if err != nil {
Expand All @@ -667,6 +668,7 @@ func (c *StandardHttpClient) getFork(ctx context.Context, stateId string) (ForkR
}
return fork, nil
}
*/

// Get validators
func (c *StandardHttpClient) getValidators(ctx context.Context, stateId string, pubkeys []string) (ValidatorsResponse, error) {
Expand Down
4 changes: 2 additions & 2 deletions config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func GetPortModes(warningOverride string) []*ParameterOption[RpcPortMode] {
func GetExternalIP() (net.IP, error) {
// Try IPv4 first
ip4Consensus := externalip.DefaultConsensus(nil, nil)
ip4Consensus.UseIPProtocol(4)
_ = ip4Consensus.UseIPProtocol(4)
if ip, err := ip4Consensus.ExternalIP(); err == nil {
return ip, nil
}

// Try IPv6 as fallback
ip6Consensus := externalip.DefaultConsensus(nil, nil)
ip6Consensus.UseIPProtocol(6)
_ = ip6Consensus.UseIPProtocol(6)
return ip6Consensus.ExternalIP()
}

Expand Down
5 changes: 2 additions & 3 deletions node/validator/keystore/lodestar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keystore

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -80,7 +79,7 @@ func (ks *LodestarKeystoreManager) StoreValidatorKey(key *eth2types.BLSPrivateKe
}

// Write secret to disk
if err := ioutil.WriteFile(secretFilePath, []byte(password), FileMode); err != nil {
if err := os.WriteFile(secretFilePath, []byte(password), FileMode); err != nil {
return fmt.Errorf("error writing validator secret to disk: %w", err)
}

Expand All @@ -93,7 +92,7 @@ func (ks *LodestarKeystoreManager) StoreValidatorKey(key *eth2types.BLSPrivateKe
}

// Write key store to disk
if err := ioutil.WriteFile(keyFilePath, keyStoreBytes, FileMode); err != nil {
if err := os.WriteFile(keyFilePath, keyStoreBytes, FileMode); err != nil {
return fmt.Errorf("error writing validator key to disk: %w", err)
}
return nil
Expand Down
6 changes: 2 additions & 4 deletions utils/input/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func ValidateWalletMnemonic(name, value string) (string, error) {

// Validate a timezone location
func ValidateTimezoneLocation(name, value string) (string, error) {
if !regexp.MustCompile("^([a-zA-Z_]{2,}\\/)+[a-zA-Z_]{2,}$").MatchString(value) {
if !regexp.MustCompile(`^([a-zA-Z_]{2,}\/)+[a-zA-Z_]{2,}$`).MatchString(value) {
return "", fmt.Errorf("Invalid %s '%s' - must be in the format 'Country/City'", name, value)
}
return value, nil
Expand Down Expand Up @@ -260,9 +260,7 @@ func ValidatePubkey(name, value string) (beacon.ValidatorPubkey, error) {
// Validate a hex-encoded byte array
func ValidateByteArray(name, value string) ([]byte, error) {
// Remove a 0x prefix if present
if strings.HasPrefix(value, "0x") {
value = value[2:]
}
value = strings.TrimPrefix(value, "0x")

// Try to parse the string (removing the prefix)
bytes, err := hex.DecodeString(value)
Expand Down

0 comments on commit c6452ca

Please sign in to comment.