Skip to content

Commit

Permalink
address nits
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Sep 29, 2021
1 parent 1559d15 commit 958d804
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
14 changes: 7 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ func getNetworkConfig(v *viper.Viper, halflife time.Duration) (network.Config, e
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListGossipFreqKey)
case config.GetVersionTimeout < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkGetVersionTimeoutKey)
case config.PeerListStakerGossipFraction < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkPeerListStakerGossipFractionKey)
case config.PeerListStakerGossipFraction < 1:
return network.Config{}, fmt.Errorf("%s must be >= 1", NetworkPeerListStakerGossipFractionKey)
case config.MaxReconnectDelay < 0:
return network.Config{}, fmt.Errorf("%s must be >= 0", NetworkMaxReconnectDelayKey)
case config.InitialReconnectDelay < 0:
Expand Down Expand Up @@ -772,15 +772,15 @@ func readSubnetConfigs(subnetConfigPath string, subnetIDs []ids.ID, defaultSubne
for _, subnetID := range subnetIDs {
filePath := filepath.Join(subnetConfigPath, subnetID.String()+subnetConfigFileExt)
fileInfo, err := os.Stat(filePath)
if errors.Is(err, os.ErrNotExist) {
switch {
case errors.Is(err, os.ErrNotExist):
// this subnet config does not exist, move to the next one
continue
}
if err != nil {
case err != nil:
return nil, err
case fileInfo.IsDir():
}

if fileInfo.IsDir() {
if err != nil {
return nil, fmt.Errorf("%q is a directory, expected a file", fileInfo.Name())
}

Expand Down
6 changes: 3 additions & 3 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func addNodeFlags(fs *flag.FlagSet) {
fs.Duration(NetworkPingTimeoutKey, constants.DefaultPingPongTimeout, "Timeout value for Ping-Pong with a peer.")
fs.Duration(NetworkPingFrequencyKey, constants.DefaultPingFrequency, "Frequency of pinging other peers.")

fs.Bool(NetworkCompressionEnabledKey, true, "If true, compress Put, PushQuery, PeerList and Multiput messages sent to peers that support compression")
fs.Bool(NetworkCompressionEnabledKey, true, "If true, compress certain outbound messages. This node will be able to parse compressed inbound messages regardless of this flag's value")
fs.Duration(NetworkMaxClockDifferenceKey, time.Minute, "Max allowed clock difference value between this node and peers.")
fs.Bool(NetworkAllowPrivateIPsKey, true, "Allows the node to connect peers with private IPs")
fs.Bool(NetworkRequireValidatorToConnectKey, false, "Requires a connection to have a least one validator to be made")
fs.Bool(NetworkRequireValidatorToConnectKey, false, "If true, this node will only maintain a connection with another node if this node is a validator, the other node is a validator, or the other node is a beacon")
// Peer alias configuration
fs.Duration(PeerAliasTimeoutKey, 10*time.Minute, "How often the node will attempt to connect "+
"to an IP address previously associated with a peer (i.e. a peer alias).")
Expand All @@ -163,7 +163,7 @@ func addNodeFlags(fs *flag.FlagSet) {
fs.Duration(ConsensusShutdownTimeoutKey, 5*time.Second, "Timeout before killing an unresponsive chain.")
fs.Uint(ConsensusGossipAcceptedFrontierSizeKey, 35, "Number of peers to gossip to when gossiping accepted frontier")
fs.Uint(ConsensusGossipOnAcceptSizeKey, 20, "Number of peers to gossip to each accepted container to")
fs.Uint(AppGossipNonValidatorSizeKey, 2, "Number of peers to gossip an AppGossip message to")
fs.Uint(AppGossipNonValidatorSizeKey, 2, "Number of peers (which may be validators or non-validators) to gossip an AppGossip message to")
fs.Uint(AppGossipValidatorSizeKey, 4, "Number of validators to gossip an AppGossip message to")

// Inbound Throttling
Expand Down
2 changes: 1 addition & 1 deletion database/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package database
Expand Down
2 changes: 1 addition & 1 deletion health/check.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package health
Expand Down
2 changes: 1 addition & 1 deletion health/checkable.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package health
Expand Down
2 changes: 1 addition & 1 deletion health/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package health
Expand Down
24 changes: 13 additions & 11 deletions utils/storage/storage_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,31 @@ func FileExists(filePath string) (bool, error) {
func ReadFileWithName(parentDir string, fileNameNoExt string) ([]byte, error) {
filePath := filepath.Join(parentDir, fileNameNoExt)
files, err := filepath.Glob(filePath + ".*") // all possible extensions
if err != nil {
switch {
case err != nil:
return nil, err
}
if len(files) > 1 {
case len(files) > 1:
return nil, fmt.Errorf(`too many files matched "%s.*" in %s`, fileNameNoExt, parentDir)
}
if len(files) == 0 { // no file found, return nothing
case len(files) == 0:
// no file found, return nothing
return nil, nil
default:
return ioutil.ReadFile(files[0])
}
return ioutil.ReadFile(files[0])
}

// folderExists checks if a folder exists before we
// try using it to prevent further errors.
func FolderExists(filePath string) (bool, error) {
info, err := os.Stat(filePath)
if err == nil {
return info.IsDir(), nil
}
if errors.Is(err, os.ErrNotExist) {
switch {
case errors.Is(err, os.ErrNotExist):
return false, nil
case err != nil:
return false, err
default:
return info.IsDir(), nil
}
return false, err
}

func DirSize(path string) (uint64, error) {
Expand Down

0 comments on commit 958d804

Please sign in to comment.