diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-01-06 21:42:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 21:42:03 +0800 |
commit | 8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184 (patch) | |
tree | 92a336065bddcd620798e8f552432e3ed62ee14a /cmd/utils | |
parent | e0ee0cc66a4416edd47232649f4d4bca4a5e3c07 (diff) | |
parent | d3b751e4d94f95f6cc89544852f2d5811e075665 (diff) | |
download | dexon-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.gz dexon-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.zst dexon-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.zip |
Merge pull request #3518 from fjl/ethclient-dependency-cleanup
core/types: dependency cleanup
Diffstat (limited to 'cmd/utils')
-rw-r--r-- | cmd/utils/flags.go | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c5f38fe93..18745e557 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -337,10 +337,10 @@ var ( Usage: "Network listening port", Value: 30303, } - BootnodesFlag = cli.StringFlag{ + BootnodesFlag = cli.StringSliceFlag{ Name: "bootnodes", Usage: "Comma separated enode URLs for P2P discovery bootstrap", - Value: "", + Value: nil, } NodeKeyFileFlag = cli.StringFlag{ Name: "nodekey", @@ -485,17 +485,15 @@ func makeNodeUserIdent(ctx *cli.Context) string { // MakeBootstrapNodes creates a list of bootstrap nodes from the command line // flags, reverting to pre-configured ones if none have been specified. func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { - // Return pre-configured nodes if none were manually requested - if !ctx.GlobalIsSet(BootnodesFlag.Name) { - if ctx.GlobalBool(TestNetFlag.Name) { - return params.TestnetBootnodes - } - return params.MainnetBootnodes + urls := params.MainnetBootnodes + if ctx.GlobalIsSet(BootnodesFlag.Name) { + urls = ctx.GlobalStringSlice(BootnodesFlag.Name) + } else if ctx.GlobalBool(TestNetFlag.Name) { + urls = params.TestnetBootnodes } - // Otherwise parse and use the CLI bootstrap nodes - bootnodes := []*discover.Node{} - for _, url := range strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",") { + bootnodes := make([]*discover.Node, 0, len(urls)) + for _, url := range urls { node, err := discover.ParseNode(url) if err != nil { glog.V(logger.Error).Infof("Bootstrap URL %s: %v\n", url, err) @@ -509,14 +507,13 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { // MakeBootstrapNodesV5 creates a list of bootstrap nodes from the command line // flags, reverting to pre-configured ones if none have been specified. func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node { - // Return pre-configured nodes if none were manually requested - if !ctx.GlobalIsSet(BootnodesFlag.Name) { - return params.DiscoveryV5Bootnodes + urls := params.DiscoveryV5Bootnodes + if ctx.GlobalIsSet(BootnodesFlag.Name) { + urls = ctx.GlobalStringSlice(BootnodesFlag.Name) } - // Otherwise parse and use the CLI bootstrap nodes - bootnodes := []*discv5.Node{} - for _, url := range strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",") { + bootnodes := make([]*discv5.Node, 0, len(urls)) + for _, url := range urls { node, err := discv5.ParseNode(url) if err != nil { glog.V(logger.Error).Infof("Bootstrap URL %s: %v\n", url, err) |