diff options
Diffstat (limited to 'cmd/puppeth/wizard_intro.go')
-rw-r--r-- | cmd/puppeth/wizard_intro.go | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/cmd/puppeth/wizard_intro.go b/cmd/puppeth/wizard_intro.go index 2d9a097ee..84998afc9 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" ) @@ -63,7 +64,7 @@ func (w *wizard) run() { for { w.network = w.readString() if !strings.Contains(w.network, " ") { - fmt.Printf("Sweet, you can set this via --network=%s next time!\n\n", w.network) + fmt.Printf("\nSweet, you can set this via --network=%s next time!\n\n", w.network) break } log.Error("I also like to live dangerously, still no spaces") @@ -80,22 +81,33 @@ 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) } - w.networkStats(false) + pend.Wait() + w.networkStats() } // Basics done, loop ad infinitum about what to do for { fmt.Println() fmt.Println("What would you like to do? (default = stats)") fmt.Println(" 1. Show network stats") - if w.conf.genesis == nil { + if w.conf.Genesis == nil { fmt.Println(" 2. Configure new genesis") } else { fmt.Println(" 2. Manage existing genesis") @@ -110,15 +122,14 @@ func (w *wizard) run() { } else { fmt.Println(" 4. Manage network components") } - //fmt.Println(" 5. ProTips for common usecases") choice := w.read() switch { case choice == "" || choice == "1": - w.networkStats(false) + w.networkStats() case choice == "2": - if w.conf.genesis == nil { + if w.conf.Genesis == nil { w.makeGenesis() } else { w.manageGenesis() @@ -126,7 +137,7 @@ func (w *wizard) run() { case choice == "3": if len(w.servers) == 0 { if w.makeServer() != "" { - w.networkStats(false) + w.networkStats() } } else { w.manageServers() @@ -138,9 +149,6 @@ func (w *wizard) run() { w.manageComponents() } - case choice == "5": - w.networkStats(true) - default: log.Error("That's not something I can do") } |