From d9890a6a8fc245c31dd0852c5fb0e1081708c4bc Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 5 Oct 2020 12:50:26 +0200 Subject: [PATCH] cmd/faucet: enable DNS discovery for known networks (#21636) --- cmd/faucet/faucet.go | 2 ++ cmd/utils/flags.go | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 7dc5536eba..346c412acb 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -43,6 +43,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -241,6 +242,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u cfg.SyncMode = downloader.LightSync cfg.NetworkId = network cfg.Genesis = genesis + utils.SetDNSDiscoveryDefaults(&cfg, genesis.ToBlock(nil).Hash()) lesBackend, err := les.New(stack, &cfg) if err != nil { return nil, fmt.Errorf("Failed to register the Ethereum service: %w", err) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 47d663eeef..55b751d625 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1590,19 +1590,19 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { cfg.NetworkId = 3 } cfg.Genesis = core.DefaultRopstenGenesisBlock() - setDNSDiscoveryDefaults(cfg, params.RopstenGenesisHash) + SetDNSDiscoveryDefaults(cfg, params.RopstenGenesisHash) case ctx.GlobalBool(RinkebyFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 4 } cfg.Genesis = core.DefaultRinkebyGenesisBlock() - setDNSDiscoveryDefaults(cfg, params.RinkebyGenesisHash) + SetDNSDiscoveryDefaults(cfg, params.RinkebyGenesisHash) case ctx.GlobalBool(GoerliFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 5 } cfg.Genesis = core.DefaultGoerliGenesisBlock() - setDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash) + SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash) case ctx.GlobalBool(YoloV1Flag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 133519467574833 // "yolov1" @@ -1656,14 +1656,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { } default: if cfg.NetworkId == 1 { - setDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash) + SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash) } } } -// setDNSDiscoveryDefaults configures DNS discovery with the given URL if +// SetDNSDiscoveryDefaults configures DNS discovery with the given URL if // no URLs are set. -func setDNSDiscoveryDefaults(cfg *eth.Config, genesis common.Hash) { +func SetDNSDiscoveryDefaults(cfg *eth.Config, genesis common.Hash) { if cfg.DiscoveryURLs != nil { return // already set through flags/config }