mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
cmd/puppeth: allow specifying a version for geth and faucet
This commit is contained in:
parent
06d40d37b8
commit
a9a5bc34fb
5 changed files with 46 additions and 3 deletions
|
|
@ -33,7 +33,7 @@ import (
|
|||
// faucetDockerfile is the Dockerfile required to build a faucet container to
|
||||
// grant crypto tokens based on GitHub authentications.
|
||||
var faucetDockerfile = `
|
||||
FROM ethereum/client-go:alltools-latest
|
||||
FROM ethereum/client-go:alltools-{{.Version}}
|
||||
|
||||
ADD genesis.json /genesis.json
|
||||
ADD account.json /account.json
|
||||
|
|
@ -90,6 +90,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
|
|||
|
||||
dockerfile := new(bytes.Buffer)
|
||||
template.Must(template.New("").Parse(faucetDockerfile)).Execute(dockerfile, map[string]interface{}{
|
||||
"Version": config.node.version,
|
||||
"NetworkID": config.node.network,
|
||||
"Bootnodes": strings.Join(bootnodes, ","),
|
||||
"Ethstats": config.node.ethstats,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import (
|
|||
|
||||
// nodeDockerfile is the Dockerfile required to run an Ethereum node.
|
||||
var nodeDockerfile = `
|
||||
FROM ethereum/client-go:latest
|
||||
FROM ethereum/client-go:{{.Version}}
|
||||
|
||||
ADD genesis.json /genesis.json
|
||||
{{if .Unlock}}
|
||||
|
|
@ -97,6 +97,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
|
|||
}
|
||||
dockerfile := new(bytes.Buffer)
|
||||
template.Must(template.New("").Parse(nodeDockerfile)).Execute(dockerfile, map[string]interface{}{
|
||||
"Version": config.version,
|
||||
"NetworkID": config.network,
|
||||
"Port": config.port,
|
||||
"Peers": config.peersTotal,
|
||||
|
|
@ -165,6 +166,7 @@ type nodeInfos struct {
|
|||
gasTarget float64
|
||||
gasLimit float64
|
||||
gasPrice float64
|
||||
version string
|
||||
}
|
||||
|
||||
// Report converts the typed struct into a plain string->string map, containing
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -324,3 +325,31 @@ func (w *wizard) readIPAddress() string {
|
|||
return text
|
||||
}
|
||||
}
|
||||
|
||||
// readDefaultAddress reads a single line from stdin, trimming if from spaces and
|
||||
// converts it to either a version in the form "v1.8.15" or "latest". If an empty
|
||||
// line is entered, the default value is returned.
|
||||
func (w *wizard) readDefaultVersion(def string) string {
|
||||
for {
|
||||
fmt.Printf("> ")
|
||||
text, err := w.in.ReadString('\n')
|
||||
if err != nil {
|
||||
log.Crit("Failed to read user input", "err", err)
|
||||
}
|
||||
if text = strings.TrimSpace(text); text == "" {
|
||||
return def
|
||||
} else if text == "latest" {
|
||||
return text
|
||||
}
|
||||
|
||||
// Match something like 1.8.15 or 1.8.0
|
||||
regex := regexp.MustCompile("^\\d+\\.\\d+\\.\\d+$")
|
||||
if !regex.Match([]byte(strings.TrimSpace(text))) {
|
||||
log.Error("Invalid input, expected a semantic version in the form 1.8.15")
|
||||
continue
|
||||
}
|
||||
|
||||
// Convert to v1.8.15 (the format used for the ethereum docker images)
|
||||
return "v" + text
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ func (w *wizard) deployFaucet() {
|
|||
infos, err := checkFaucet(client, w.network)
|
||||
if err != nil {
|
||||
infos = &faucetInfos{
|
||||
node: &nodeInfos{port: 30303, peersTotal: 25},
|
||||
node: &nodeInfos{port: 30303, peersTotal: 25, version: "latest"},
|
||||
port: 80,
|
||||
host: client.server,
|
||||
amount: 1,
|
||||
|
|
@ -102,6 +102,11 @@ func (w *wizard) deployFaucet() {
|
|||
infos.captchaSecret = w.readPassword()
|
||||
}
|
||||
}
|
||||
// Figure out which version of faucet to use
|
||||
fmt.Println()
|
||||
fmt.Printf("Which version of faucet to use? (default = %s)\n", infos.node.version)
|
||||
infos.node.version = w.readDefaultVersion(infos.node.version)
|
||||
|
||||
// Figure out where the user wants to store the persistent data
|
||||
fmt.Println()
|
||||
if infos.node.datadir == "" {
|
||||
|
|
|
|||
|
|
@ -55,9 +55,15 @@ func (w *wizard) deployNode(boot bool) {
|
|||
}
|
||||
existed := err == nil
|
||||
|
||||
infos.version = "latest"
|
||||
infos.genesis, _ = json.MarshalIndent(w.conf.Genesis, "", " ")
|
||||
infos.network = w.conf.Genesis.Config.ChainID.Int64()
|
||||
|
||||
// Figure out which version of geth to use
|
||||
fmt.Println()
|
||||
fmt.Printf("Which version of geth to use? (default = %s)\n", infos.version)
|
||||
infos.version = w.readDefaultVersion(infos.version)
|
||||
|
||||
// Figure out where the user wants to store the persistent data
|
||||
fmt.Println()
|
||||
if infos.datadir == "" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue