Skip to content

Commit

Permalink
Merge pull request #16 from NetSepio/rushikesh
Browse files Browse the repository at this point in the history
chain name fix
  • Loading branch information
Rushikeshnimkar authored Jul 6, 2024
2 parents 6962c4d + 583f95f commit 2468987
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
27 changes: 27 additions & 0 deletions core/chainName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package core

import (
"fmt"
"log"
"os"

"github.com/joho/godotenv"
)

var ChainName string

// Function to load the chain name from the environment and save it to the global variable
func LoadChainName() {
// Load environment variables from the .env file
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file")
}

// Get the CHAIN_NAME variable from the environment
ChainName = os.Getenv("CHAIN_NAME")
if ChainName == "" {
log.Fatalf("CHAIN_NAME environment variable is not set")
}
fmt.Printf("Chain Name: %s\n", ChainName)
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ func init() {
}
// Check if loading environment variables from .env file is required
if os.Getenv("LOAD_CONFIG_FILE") == "" {

// Load environment variables from .env file
err = godotenv.Load()
if err != nil {
log.WithFields(util.StandardFields).Fatalf("Error in reading the config file: %v", err)

}
}
core.GetIPInfo()
Expand Down Expand Up @@ -133,6 +135,7 @@ func main() {
core.GenerateWalletAddress()
// core.GenerateWalletAddressSolana()
// core.GenerateEthereumWalletAddress()
core.LoadChainName()

go p2p.Init()
//running updater
Expand Down
4 changes: 2 additions & 2 deletions util/pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type NodeStatus struct {
UploadSpeed float64 `json:"uploadSpeed"`
RegistrationTime int64 `json:"registrationTime"` //StartTimeStamp
LastPing int64 `json:"lastPing"`
Chain string `json:"chainName"`
ChainName string `json:"chainName"`
WalletAddress string `json:"walletAddress"`
Version string `json:"version"`
CodeHash string `json:"codeHash"`
Expand Down Expand Up @@ -137,7 +137,7 @@ func CreateNodeStatus(address string, id string, startTimeStamp int64, name stri
RegistrationTime: startTimeStamp,
Name: name,
WalletAddress: core.WalletAddress,
Chain: os.Getenv("CHAIN_NAME"),
ChainName: core.ChainName,
Version: "v1",
CodeHash: "xxxxxxxxxxxxx",
SystemInfo: ToJSON(GetOSInfo()),
Expand Down

0 comments on commit 2468987

Please sign in to comment.