packages/hyprspace: better swarm key handling

This commit is contained in:
Max Headroom 2022-09-25 23:37:25 +02:00
parent a1ddafe045
commit 8b6e5b831c

View file

@ -63,9 +63,15 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network.
return
}
swarmKey, err := os.Open(os.Getenv("HYPRSPACE_SWARM_KEY"))
if err != nil {
return
var swarmKey *os.File
swarmKeyFile, ok := os.LookupEnv("HYPRSPACE_SWARM_KEY")
if ok {
fmt.Println("[+] Using swarm key " + swarmKeyFile)
swarmKey, err = os.Open(swarmKeyFile)
if err != nil {
return
}
defer swarmKey.Close()
}
extraBootstrapNodes := []string{}
ipfsApiStr, ok := os.LookupEnv("HYPRSPACE_IPFS_API")