From 8a28408616cab76bf756170a4f39025c821e4d21 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Tue, 2 May 2017 13:52:51 +0300 Subject: cmd/faucet, cmd/puppeth: support multi-tiered faucet --- cmd/puppeth/module_faucet.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'cmd/puppeth/module_faucet.go') 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"], -- cgit