Skip to content

Commit

Permalink
Use public endpoint if necessary.
Browse files Browse the repository at this point in the history
Provide access to public endpoint if no other connection available.
  • Loading branch information
mcdee committed Feb 21, 2023
1 parent ec9f5b8 commit 15d58e2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions cmd/validator/credentials/set/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import (
// a lot of data for an unsophisticated audience so it's easier to set a higher timeout..
var minTimeout = 2 * time.Minute

// defaultBeaconNode is used if no other connection is supplied.
var defaultBeaconNode = "http://mainnet-consensus.attestant.io/"

// validatorPath is the regular expression that matches a validator path.
var validatorPath = regexp.MustCompile("^m/12381/3600/[0-9]+/0/0$")

Expand Down Expand Up @@ -701,15 +704,27 @@ func (c *command) setup(ctx context.Context) error {
if c.timeout < minTimeout {
if c.debug {
fmt.Fprintf(os.Stderr, "Increasing timeout to %v\n", minTimeout)
c.timeout = minTimeout
}
c.timeout = minTimeout
}

// Connect to the consensus node.
var err error
c.consensusClient, err = util.ConnectToBeaconNode(ctx, c.connection, c.timeout, c.allowInsecureConnections)
if err != nil {
return errors.Wrap(err, "failed to connect to consensus node")
if c.connection != "" {
// The user provided a connection, so don't second-guess them by using a different node.
return err
}

// The user did not provide a connection, so attempt to use the default node.
if c.debug {
fmt.Fprintf(os.Stderr, "No node connection, attempting to use %s\n", defaultBeaconNode)
}
c.consensusClient, err = util.ConnectToBeaconNode(ctx, defaultBeaconNode, c.timeout, c.allowInsecureConnections)
if err != nil {
return err
}
}

// Set up chaintime.
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// ReleaseVersion is the release version of the codebase.
// Usually overridden by tag names when building binaries.
var ReleaseVersion = "local build (latest release 1.28.0)"
var ReleaseVersion = "local build (latest release 1.28.1)"

// versionCmd represents the version command.
var versionCmd = &cobra.Command{
Expand Down

0 comments on commit 15d58e2

Please sign in to comment.