Skip to content

Commit

Permalink
fix: panic when discv5 is enabled while running service node
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaprem committed Nov 14, 2023
1 parent a5ce5df commit 72db096
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cmd/waku/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ func Execute(options NodeOptions) error {
return nonRecoverError(err)
}

var discoveredNodes []dnsdisc.DiscoveredNode
if options.DNSDiscovery.Enable {
if len(options.DNSDiscovery.URLs.Value()) == 0 {
return nonRecoverErrorMsg("DNS discovery URL is required")
}
discoveredNodes = node.GetNodesFromDNSDiscovery(logger, ctx, options.DNSDiscovery.Nameserver, options.DNSDiscovery.URLs.Value())
}
if options.DiscV5.Enable {
discv5Opts, err := node.GetDiscv5Option(discoveredNodes, options.DiscV5.Nodes.Value(), options.DiscV5.Port, options.DiscV5.AutoUpdate)
if err != nil {
logger.Fatal("parsing ENR", zap.Error(err))
}
nodeOpts = append(nodeOpts, discv5Opts)
}

wakuNode, err := node.New(nodeOpts...)
if err != nil {
return fmt.Errorf("could not instantiate waku: %w", err)
Expand All @@ -315,21 +330,6 @@ func Execute(options NodeOptions) error {
}
}

var discoveredNodes []dnsdisc.DiscoveredNode
if options.DNSDiscovery.Enable {
if len(options.DNSDiscovery.URLs.Value()) == 0 {
return nonRecoverErrorMsg("DNS discovery URL is required")
}
discoveredNodes = node.GetNodesFromDNSDiscovery(logger, ctx, options.DNSDiscovery.Nameserver, options.DNSDiscovery.URLs.Value())
}
if options.DiscV5.Enable {
discv5Opts, err := node.GetDiscv5Option(discoveredNodes, options.DiscV5.Nodes.Value(), options.DiscV5.Port, options.DiscV5.AutoUpdate)
if err != nil {
logger.Fatal("parsing ENR", zap.Error(err))
}
nodeOpts = append(nodeOpts, discv5Opts)
}

if err = wakuNode.Start(ctx); err != nil {
return nonRecoverError(err)
}
Expand Down

0 comments on commit 72db096

Please sign in to comment.