Skip to content

Commit 6a8aa31

Browse files
authored
main: fix spurious error log when running without -chain or -attach (ethereum#275)
This enforces what was an implicit requirement that the faucet be configured explicitly for a chain configuration. Fixing https://github.com/etclabscore/core-geth/pull/269/files#r551442004, the bespoke log happens whent neither -attach nor -chain.xxx is set, the behavior for which should be undefined. Date: 2021-01-04 12:37:10-06:00 Signed-off-by: meows <b5c6@protonmail.com>
1 parent 2f118b4 commit 6a8aa31

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

cmd/faucet/faucet.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ func parseChainFlags() (gs *genesisT.Genesis, bs string, netid uint64) {
203203

204204
// auditFlagUse ensures that exclusive/incompatible flag values are not set.
205205
// If invalid use if found, the program exits with log.Crit.
206-
func auditFlagUse() {
206+
func auditFlagUse(genesis *genesisT.Genesis) {
207+
if genesis == nil && *attachFlag == "" {
208+
log.Crit("no -chain.<identity> configured and no attach target; use either -chain.<identity> or -attach.")
209+
}
207210
if *statsFlag != "" && *attachFlag != "" {
208211
log.Crit("flags are incompatible", "flags", []string{"ethstats", "attach"}, "values", []*string{statsFlag, attachFlag})
209212
}
@@ -229,7 +232,16 @@ func main() {
229232
flag.Parse()
230233
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*logFlag), log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
231234

232-
auditFlagUse()
235+
// Load and parse the genesis block requested by the user
236+
var genesis *genesisT.Genesis
237+
var enodes []*discv5.Node
238+
var blob []byte
239+
240+
// client will be used if the faucet is attaching. If not it won't be touched.
241+
var client *ethclient.Client
242+
243+
genesis, *bootFlag, *netFlag = parseChainFlags()
244+
auditFlagUse(genesis)
233245

234246
// Construct the payout tiers
235247
amounts := make([]string, *tiersFlag)
@@ -274,16 +286,6 @@ func main() {
274286
log.Crit("Failed to render the faucet template", "err", err)
275287
}
276288

277-
// Load and parse the genesis block requested by the user
278-
var genesis *genesisT.Genesis
279-
var enodes []*discv5.Node
280-
var blob []byte
281-
282-
// client will be used if the faucet is attaching. If not it won't be touched.
283-
var client *ethclient.Client
284-
285-
genesis, *bootFlag, *netFlag = parseChainFlags()
286-
287289
if genesis != nil {
288290
log.Info("Using chain/net config", "network id", *netFlag, "bootnodes", *bootFlag, "chain config", fmt.Sprintf("%v", genesis.Config))
289291

0 commit comments

Comments
 (0)