updateBootstrapNodes creates a list of bootstrap nodes from the command line flags, reverting to pre-configured ones if none have been specified.
(ctx *cli.Context, cfg *p2p.Config)
| 127 | // updateBootstrapNodes creates a list of bootstrap nodes from the command line |
| 128 | // flags, reverting to pre-configured ones if none have been specified. |
| 129 | func updateBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { |
| 130 | urls := configs.Bootnodes() |
| 131 | if ctx.IsSet(flags.BootnodesFlagName) { |
| 132 | urls = strings.Split(ctx.String(flags.BootnodesFlagName), ",") |
| 133 | } |
| 134 | |
| 135 | cfg.BootstrapNodes = make([]*discover.Node, 0, len(urls)) |
| 136 | newUrls, err := configs.ConvertNodeURL(urls) |
| 137 | log.Debug("convert bootnode urls", "original urls", urls, "new urls", newUrls) |
| 138 | if err != nil { |
| 139 | log.Fatal("convertValidators failed", "error", err) |
| 140 | } |
| 141 | |
| 142 | for _, url := range newUrls { |
| 143 | node, err := discover.ParseNode(url) |
| 144 | if err != nil { |
| 145 | log.Error("Bootstrap URL invalid", "enode", url, "err", err) |
| 146 | continue |
| 147 | } |
| 148 | cfg.BootstrapNodes = append(cfg.BootstrapNodes, node) |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // updateValidatorNodes creates a list of validator nodes from the command line |
| 153 | // flags, reverting to pre-configured ones if none have been specified. |
no test coverage detected