mirror of https://github.com/status-im/go-waku.git
fix: panic when discv5 is enabled while running service node (#897)
This commit is contained in:
parent
a5ce5dfaa4
commit
392558ec8e
|
@ -293,6 +293,21 @@ func Execute(options NodeOptions) error {
|
||||||
return nonRecoverError(err)
|
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...)
|
wakuNode, err := node.New(nodeOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not instantiate waku: %w", err)
|
return fmt.Errorf("could not instantiate waku: %w", err)
|
||||||
|
@ -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 {
|
if err = wakuNode.Start(ctx); err != nil {
|
||||||
return nonRecoverError(err)
|
return nonRecoverError(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,7 +467,7 @@ func (pm *PeerManager) AddPeer(address ma.Multiaddr, origin wps.Origin, pubsubTo
|
||||||
return pData, nil
|
return pData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect establishes a connection to a peer.
|
// Connect establishes a connection to a
|
||||||
func (pm *PeerManager) Connect(pData *service.PeerData) {
|
func (pm *PeerManager) Connect(pData *service.PeerData) {
|
||||||
go pm.peerConnector.PushToChan(*pData)
|
go pm.peerConnector.PushToChan(*pData)
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ func (pm *PeerManager) RemovePeer(peerID peer.ID) {
|
||||||
// If relay proto is passed, it is not added to serviceSlot.
|
// If relay proto is passed, it is not added to serviceSlot.
|
||||||
func (pm *PeerManager) addPeerToServiceSlot(proto protocol.ID, peerID peer.ID) {
|
func (pm *PeerManager) addPeerToServiceSlot(proto protocol.ID, peerID peer.ID) {
|
||||||
if proto == relay.WakuRelayID_v200 {
|
if proto == relay.WakuRelayID_v200 {
|
||||||
pm.logger.Warn("Cannot add Relay peer to service peer slots")
|
pm.logger.Debug("cannot add Relay peer to service peer slots")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue