aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-05 20:56:06 +0800
committerFelix Lange <fjl@twurst.com>2017-01-06 21:15:21 +0800
commitb9683d3748dcb73ab5a5474334eaf157267d9c4a (patch)
treedc778d15d01f8e8fdbb7c7ffa80acc9729645bd4 /cmd
parentbbc4ea4ae8e8a962deae3d5693d9d4a9376eab88 (diff)
downloaddexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar.gz
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar.bz2
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar.lz
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar.xz
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.tar.zst
dexon-b9683d3748dcb73ab5a5474334eaf157267d9c4a.zip
params: avoid importing p2p/discover for bootnodes
params is imported by leaf-ish library packages and should not pull in the p2p stack.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/utils/flags.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 9df891f78..1f8822976 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)