aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/puppeth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-02 18:52:51 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-05-04 16:42:43 +0800
commit8a28408616cab76bf756170a4f39025c821e4d21 (patch)
tree3211df8c26ac55f4743827edf7af461fb233a3e1 /cmd/puppeth
parente1dc7ece624a2f539b71f1dfb5901047f7a9f214 (diff)
downloaddexon-8a28408616cab76bf756170a4f39025c821e4d21.tar.gz
dexon-8a28408616cab76bf756170a4f39025c821e4d21.tar.zst
dexon-8a28408616cab76bf756170a4f39025c821e4d21.zip
cmd/faucet, cmd/puppeth: support multi-tiered faucet
Diffstat (limited to 'cmd/puppeth')
-rw-r--r--cmd/puppeth/module_faucet.go16
-rw-r--r--cmd/puppeth/wizard_faucet.go8
2 files changed, 19 insertions, 5 deletions
diff --git a/cmd/puppeth/module_faucet.go b/cmd/puppeth/module_faucet.go
index fc957721d..5a5dc6506 100644
--- a/cmd/puppeth/module_faucet.go
+++ b/cmd/puppeth/module_faucet.go
@@ -51,10 +51,10 @@ ADD account.pass /account.pass
EXPOSE 8080
CMD [ \
- "/faucet", "--genesis", "/genesis.json", "--network", "{{.NetworkID}}", "--bootnodes", "{{.Bootnodes}}", "--ethstats", "{{.Ethstats}}", \
- "--ethport", "{{.EthPort}}", "--faucet.name", "{{.FaucetName}}", "--faucet.amount", "{{.FaucetAmount}}", "--faucet.minutes", "{{.FaucetMinutes}}", \
- "--github.user", "{{.GitHubUser}}", "--github.token", "{{.GitHubToken}}", "--account.json", "/account.json", "--account.pass", "/account.pass" \
- {{if .CaptchaToken}}, "--captcha.token", "{{.CaptchaToken}}", "--captcha.secret", "{{.CaptchaSecret}}"{{end}} \
+ "/faucet", "--genesis", "/genesis.json", "--network", "{{.NetworkID}}", "--bootnodes", "{{.Bootnodes}}", "--ethstats", "{{.Ethstats}}", "--ethport", "{{.EthPort}}", \
+ "--faucet.name", "{{.FaucetName}}", "--faucet.amount", "{{.FaucetAmount}}", "--faucet.minutes", "{{.FaucetMinutes}}", "--faucet.tiers", "{{.FaucetTiers}}", \
+ "--github.user", "{{.GitHubUser}}", "--github.token", "{{.GitHubToken}}", "--account.json", "/account.json", "--account.pass", "/account.pass" \
+ {{if .CaptchaToken}}, "--captcha.token", "{{.CaptchaToken}}", "--captcha.secret", "{{.CaptchaSecret}}"{{end}} \
]`
// faucetComposefile is the docker-compose.yml file required to deploy and maintain
@@ -75,6 +75,7 @@ services:
- ETH_NAME={{.EthName}}
- FAUCET_AMOUNT={{.FaucetAmount}}
- FAUCET_MINUTES={{.FaucetMinutes}}
+ - FAUCET_TIERS={{.FaucetTiers}}
- GITHUB_USER={{.GitHubUser}}
- GITHUB_TOKEN={{.GitHubToken}}
- CAPTCHA_TOKEN={{.CaptchaToken}}
@@ -105,6 +106,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
"FaucetName": strings.Title(network),
"FaucetAmount": config.amount,
"FaucetMinutes": config.minutes,
+ "FaucetTiers": config.tiers,
})
files[filepath.Join(workdir, "Dockerfile")] = dockerfile.Bytes()
@@ -122,6 +124,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
"CaptchaSecret": config.captchaSecret,
"FaucetAmount": config.amount,
"FaucetMinutes": config.minutes,
+ "FaucetTiers": config.tiers,
})
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
@@ -147,6 +150,7 @@ type faucetInfos struct {
port int
amount int
minutes int
+ tiers int
githubUser string
githubToken string
captchaToken string
@@ -155,7 +159,7 @@ type faucetInfos struct {
// String implements the stringer interface.
func (info *faucetInfos) String() string {
- return fmt.Sprintf("host=%s, api=%d, eth=%d, amount=%d, minutes=%d, github=%s, captcha=%v, ethstats=%s", info.host, info.port, info.node.portFull, info.amount, info.minutes, info.githubUser, info.captchaToken != "", info.node.ethstats)
+ return fmt.Sprintf("host=%s, api=%d, eth=%d, amount=%d, minutes=%d, tiers=%d, github=%s, captcha=%v, ethstats=%s", info.host, info.port, info.node.portFull, info.amount, info.minutes, info.tiers, info.githubUser, info.captchaToken != "", info.node.ethstats)
}
// checkFaucet does a health-check against an faucet server to verify whether
@@ -186,6 +190,7 @@ func checkFaucet(client *sshClient, network string) (*faucetInfos, error) {
}
amount, _ := strconv.Atoi(infos.envvars["FAUCET_AMOUNT"])
minutes, _ := strconv.Atoi(infos.envvars["FAUCET_MINUTES"])
+ tiers, _ := strconv.Atoi(infos.envvars["FAUCET_TIERS"])
// Retrieve the funding account informations
var out []byte
@@ -213,6 +218,7 @@ func checkFaucet(client *sshClient, network string) (*faucetInfos, error) {
port: port,
amount: amount,
minutes: minutes,
+ tiers: tiers,
githubUser: infos.envvars["GITHUB_USER"],
githubToken: infos.envvars["GITHUB_TOKEN"],
captchaToken: infos.envvars["CAPTCHA_TOKEN"],
diff --git a/cmd/puppeth/wizard_faucet.go b/cmd/puppeth/wizard_faucet.go
index f3fd7c2a1..66ec98c73 100644
--- a/cmd/puppeth/wizard_faucet.go
+++ b/cmd/puppeth/wizard_faucet.go
@@ -44,6 +44,7 @@ func (w *wizard) deployFaucet() {
host: client.server,
amount: 1,
minutes: 1440,
+ tiers: 3,
}
}
infos.node.genesis, _ = json.MarshalIndent(w.conf.genesis, "", " ")
@@ -68,6 +69,13 @@ func (w *wizard) deployFaucet() {
fmt.Printf("How many minutes to enforce between requests? (default = %d)\n", infos.minutes)
infos.minutes = w.readDefaultInt(infos.minutes)
+ fmt.Println()
+ fmt.Printf("How many funding tiers to feature (x2.5 amounts, x3 timeout)? (default = %d)\n", infos.tiers)
+ infos.tiers = w.readDefaultInt(infos.tiers)
+ if infos.tiers == 0 {
+ log.Error("At least one funding tier must be set")
+ return
+ }
// Accessing GitHub gists requires API authorization, retrieve it
if infos.githubUser != "" {
fmt.Println()