diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-10-19 19:40:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-11-21 21:09:32 +0800 |
commit | 7b258c96816df56e642df7e314e8052213af70fa (patch) | |
tree | 12de1da624d8e540a9f7bbf345a6a4ea15559973 /cmd/puppeth/wizard_intro.go | |
parent | 8c78449a9ef8f2a77cc1ff94f9a0a3178af21408 (diff) | |
download | dexon-7b258c96816df56e642df7e314e8052213af70fa.tar.gz dexon-7b258c96816df56e642df7e314e8052213af70fa.tar.zst dexon-7b258c96816df56e642df7e314e8052213af70fa.zip |
cmd/puppeth: concurrent server dials and health checks
Diffstat (limited to 'cmd/puppeth/wizard_intro.go')
-rw-r--r-- | cmd/puppeth/wizard_intro.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cmd/puppeth/wizard_intro.go b/cmd/puppeth/wizard_intro.go index a5fea6f85..005ee47a5 100644 --- a/cmd/puppeth/wizard_intro.go +++ b/cmd/puppeth/wizard_intro.go @@ -24,6 +24,7 @@ import ( "os" "path/filepath" "strings" + "sync" "github.com/ethereum/go-ethereum/log" ) @@ -80,14 +81,25 @@ func (w *wizard) run() { } else if err := json.Unmarshal(blob, &w.conf); err != nil { log.Crit("Previous configuration corrupted", "path", w.conf.path, "err", err) } else { + // Dial all previously known servers concurrently + var pend sync.WaitGroup for server, pubkey := range w.conf.Servers { - log.Info("Dialing previously configured server", "server", server) - client, err := dial(server, pubkey) - if err != nil { - log.Error("Previous server unreachable", "server", server, "err", err) - } - w.servers[server] = client + pend.Add(1) + + go func(server string, pubkey []byte) { + defer pend.Done() + + log.Info("Dialing previously configured server", "server", server) + client, err := dial(server, pubkey) + if err != nil { + log.Error("Previous server unreachable", "server", server, "err", err) + } + w.lock.Lock() + w.servers[server] = client + w.lock.Unlock() + }(server, pubkey) } + pend.Wait() w.networkStats() } // Basics done, loop ad infinitum about what to do |