MCPcopy Create free account
hub / github.com/CPChain/chain / updateBootstrapNodes

Function updateBootstrapNodes

cmd/cpchain/config.go:129–150  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

127// updateBootstrapNodes creates a list of bootstrap nodes from the command line
128// flags, reverting to pre-configured ones if none have been specified.
129func 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.

Callers 1

updateP2pConfigFunction · 0.85

Calls 4

DebugMethod · 0.80
FatalMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected