From e90b9a1f3346b81b5b011c234b93f258e5f13ae3 Mon Sep 17 00:00:00 2001 From: meowsbits Date: Fri, 8 Jan 2021 09:31:58 -0600 Subject: [PATCH] main: fix eth backend API initialization (#278) Date: 2021-01-08 07:16:52-06:00 Signed-off-by: meows --- cmd/faucet/faucet.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 14d10d00e120..05c1607d5aaa 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -545,27 +545,29 @@ func (f *faucet) startStack(genesis *genesisT.Genesis, port int, enodes []*discv log.Info("Config discovery", "urls", cfg.DiscoveryURLs) // Establish the backend and enable stats reporting if configured to do so. - if *statsFlag != "" { - switch *syncmodeFlag { - case "light": - lesBackend, err := les.New(stack, &cfg) - if err != nil { - return fmt.Errorf("Failed to register the Ethereum service: %w", err) - } + switch *syncmodeFlag { + case "light": + lesBackend, err := les.New(stack, &cfg) + if err != nil { + return fmt.Errorf("Failed to register the Ethereum service: %w", err) + } + if *statsFlag != "" { if err := ethstats.New(stack, lesBackend.ApiBackend, lesBackend.Engine(), *statsFlag); err != nil { return err } - case "fast", "full": - ethBackend, err := eth.New(stack, &cfg) - if err != nil { - return fmt.Errorf("Failed to register the Ethereum service: %w", err) - } + } + case "fast", "full": + ethBackend, err := eth.New(stack, &cfg) + if err != nil { + return fmt.Errorf("Failed to register the Ethereum service: %w", err) + } + if *statsFlag != "" { if err := ethstats.New(stack, ethBackend.APIBackend, ethBackend.Engine(), *statsFlag); err != nil { return err } - default: - panic("impossible to reach, this should be handled in the auditFlagUse function") } + default: + panic("impossible to reach, this should be handled in the auditFlagUse function") } // Boot up the client and ensure it connects to bootnodes