Skip to content

Commit 37cabea

Browse files
panoelevan-gray
authored andcommittedAug 4, 2024·
fly: code inspection changes
1 parent c10aeb2 commit 37cabea

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
 

‎fly/cmd/fly/main.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ func loadEnvVars() {
129129
rpcUrl = verifyEnvVar("RPC_URL")
130130
coreBridgeAddr = verifyEnvVar("CORE_BRIDGE_ADDR")
131131
credentialsFile = verifyEnvVar("CREDENTIALS_FILE")
132-
network = verifyEnvVar("NETWORK")
133132
}
134133

135134
func verifyEnvVar(key string) string {
@@ -142,16 +141,6 @@ func verifyEnvVar(key string) string {
142141

143142
func main() {
144143
loadEnvVars()
145-
if network == "mainnet" {
146-
p2pNetworkID = p2p.MainnetNetworkId
147-
p2pBootstrap = p2p.MainnetBootstrapPeers
148-
} else if network == "testnet" {
149-
p2pNetworkID = p2p.TestnetNetworkId
150-
p2pBootstrap = p2p.TestnetBootstrapPeers
151-
} else {
152-
p2pNetworkID = p2p.DevnetNetworkId
153-
p2pBootstrap = ""
154-
}
155144

156145
lvl, err := ipfslog.LevelFromString(logLevel)
157146
if err != nil {
@@ -161,6 +150,16 @@ func main() {
161150

162151
logger := ipfslog.Logger("wormhole-fly").Desugar()
163152

153+
env, err := common.ParseEnvironment(network)
154+
if err != nil || (env != common.TestNet && env != common.MainNet) {
155+
logger.Fatal("Invalid value for NETWORK, should be testnet or mainnet", zap.String("val", network))
156+
}
157+
p2pNetworkID = p2p.GetNetworkId(env)
158+
p2pBootstrap, err = p2p.GetBootstrapPeers(env)
159+
if err != nil {
160+
logger.Fatal("failed to determine the bootstrap peers from the environment", zap.String("env", string(env)), zap.Error(err))
161+
}
162+
164163
ipfslog.SetAllLoggers(lvl)
165164

166165
ctx := context.Background()

0 commit comments

Comments
 (0)
Please sign in to comment.