From 31a380c52821864ca5ade8215887f7b9195f7130 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Wed, 13 Nov 2024 11:52:05 -0600 Subject: [PATCH] Use the port for the network defined in the config if its present (#38) --- cmd/network/switch.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/network/switch.go b/cmd/network/switch.go index 8aaf105..1c4cbdd 100644 --- a/cmd/network/switch.go +++ b/cmd/network/switch.go @@ -47,7 +47,11 @@ var switchCmd = &cobra.Command{ if _, ok := cfg.NetworkOverrides.Constants[networkName]; !ok { slogs.Logr.Fatal("selected network does not exist in config's network override constants", "network", networkName) } - if _, ok := cfg.NetworkOverrides.Config[networkName]; !ok { + var ( + netConfig config.NetworkConfig + ok bool + ) + if netConfig, ok = cfg.NetworkOverrides.Config[networkName]; !ok { slogs.Logr.Fatal("selected network does not exist in config's network override config", "network", networkName) } @@ -129,6 +133,10 @@ var switchCmd = &cobra.Command{ if bootPeer := viper.GetString("switch-bootstrap-peer"); bootPeer != "" { bootstrapPeers = []string{bootPeer} } + // If there is a port in the config, use that, but still allow the flag to be the final say + if netConfig.DefaultFullNodePort != 0 { + fullNodePort = netConfig.DefaultFullNodePort + } if portFlag := viper.GetUint16("switch-full-node-port"); portFlag != 0 { fullNodePort = portFlag }