Skip to content

Commit

Permalink
main: fix spurious error log when running without -chain or -attach (e…
Browse files Browse the repository at this point in the history
…thereum#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 <[email protected]>
  • Loading branch information
meowsbits authored Jan 5, 2021
1 parent 2f118b4 commit 6a8aa31
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ func parseChainFlags() (gs *genesisT.Genesis, bs string, netid uint64) {

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

auditFlagUse()
// Load and parse the genesis block requested by the user
var genesis *genesisT.Genesis
var enodes []*discv5.Node
var blob []byte

// client will be used if the faucet is attaching. If not it won't be touched.
var client *ethclient.Client

genesis, *bootFlag, *netFlag = parseChainFlags()
auditFlagUse(genesis)

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

// Load and parse the genesis block requested by the user
var genesis *genesisT.Genesis
var enodes []*discv5.Node
var blob []byte

// client will be used if the faucet is attaching. If not it won't be touched.
var client *ethclient.Client

genesis, *bootFlag, *netFlag = parseChainFlags()

if genesis != nil {
log.Info("Using chain/net config", "network id", *netFlag, "bootnodes", *bootFlag, "chain config", fmt.Sprintf("%v", genesis.Config))

Expand Down

0 comments on commit 6a8aa31

Please sign in to comment.