From d438c21f79de9267e7aa9aca73c16cbbe47a27f5 Mon Sep 17 00:00:00 2001 From: AYAHASSAN287 <49167455+AYAHASSAN287@users.noreply.github.com> Date: Wed, 26 Feb 2025 12:21:30 +0200 Subject: [PATCH] Update waku/nwaku.go Co-authored-by: gabrielmer <101006718+gabrielmer@users.noreply.github.com> --- waku/nwaku.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/waku/nwaku.go b/waku/nwaku.go index 26969ad..dab2d1e 100644 --- a/waku/nwaku.go +++ b/waku/nwaku.go @@ -1415,20 +1415,18 @@ func StartWakuNode(nodeName string, customCfg *WakuConfig) (*WakuNode, error) { nodeCfg = *customCfg } - if nodeCfg.TcpPort == 0 || nodeCfg.Discv5UdpPort == 0 { - tcpPort, udpPort, err := GetFreePortIfNeeded(0, 0) - if err != nil { - Error("Failed to allocate unique ports: %v", err) - tcpPort, udpPort = 0, 0 - } - - if nodeCfg.TcpPort == 0 { - nodeCfg.TcpPort = tcpPort - } - if nodeCfg.Discv5UdpPort == 0 { - nodeCfg.Discv5UdpPort = udpPort - } - } + tcpPort, udpPort, err := GetFreePortIfNeeded(nodeCfg.TcpPort, nodeCfg.Discv5UdpPort) + if err != nil { + Error("Failed to allocate unique ports: %v", err) + tcpPort, udpPort = 0, 0 + } + + if nodeCfg.TcpPort == 0 { + nodeCfg.TcpPort = tcpPort + } + if nodeCfg.Discv5UdpPort == 0 { + nodeCfg.Discv5UdpPort = udpPort + } Debug("Creating %s", nodeName) node, err := NewWakuNode(&nodeCfg, nodeName)