cmd/bzzd: fix two bugs crashing bzzd if bootnodes flag given

This commit is contained in:
zelig 2016-11-28 09:00:32 +01:00
parent b92d993038
commit 36f5e2a6fc

View file

@ -23,6 +23,7 @@ import (
"os" "os"
"runtime" "runtime"
"strconv" "strconv"
"strings"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
@ -140,7 +141,8 @@ func bzzd(ctx *cli.Context) error {
// Add bootnodes as initial peers. // Add bootnodes as initial peers.
if ctx.GlobalIsSet(utils.BootnodesFlag.Name) { if ctx.GlobalIsSet(utils.BootnodesFlag.Name) {
injectBootnodes(stack.Server(), ctx.GlobalStringSlice(utils.BootnodesFlag.Name)) bootnodes := strings.Split(ctx.GlobalString(utils.BootnodesFlag.Name), ",")
injectBootnodes(stack.Server(), bootnodes)
} else { } else {
injectBootnodes(stack.Server(), defaultBootnodes) injectBootnodes(stack.Server(), defaultBootnodes)
} }
@ -243,6 +245,7 @@ func injectBootnodes(srv *p2p.Server, nodes []string) {
n, err := discover.ParseNode(url) n, err := discover.ParseNode(url)
if err != nil { if err != nil {
glog.Errorf("invalid bootnode %q", err) glog.Errorf("invalid bootnode %q", err)
continue
} }
srv.AddPeer(n) srv.AddPeer(n)
} }