From 3c92222d6c15f79fafd5822c6b05b01c1ad86c01 Mon Sep 17 00:00:00 2001
From: Martin Holst Swende <martin@swende.se>
Date: Fri, 7 Aug 2020 11:15:41 +0200
Subject: [PATCH] ethstats: overwrite old errors

---
 ethstats/ethstats.go | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go
index a76d8bf2a1..03b9a29ace 100644
--- a/ethstats/ethstats.go
+++ b/ethstats/ethstats.go
@@ -252,11 +252,11 @@ func (s *Service) loop() {
 			header.Set("origin", "http://localhost")
 			for _, url := range urls {
 				c, _, e := dialer.Dial(url, header)
-				if e == nil {
+				err = e
+				if err == nil {
 					conn = newConnectionWrapper(c)
 					break
 				}
-				err = e
 			}
 			if err != nil {
 				log.Warn("Stats server unreachable", "err", err)
@@ -271,7 +271,6 @@ func (s *Service) loop() {
 				continue
 			}
 			go s.readLoop(conn)
-
 			// Send the initial stats so our node looks decent from the get go
 			if err = s.report(conn); err != nil {
 				log.Warn("Initial stats report failed", "err", err)
-- 
GitLab