MCPcopy Create free account
hub / github.com/DOSNetwork/core / overWrite

Method overWrite

configuration/config.go:94–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func (c *Config) overWrite() (err error) {
95 ip := os.Getenv(envNodeIP)
96 if ip != "" {
97 testInput := net.ParseIP(ip)
98 if testInput.To4() == nil {
99 fmt.Printf("%v is not a valid IPv4 address\n", testInput)
100 return errors.New("not a valid IPv4 address")
101 } else {
102 c.NodeIP = ip
103 }
104 }
105 port := os.Getenv(envNodePort)
106 if port != "" {
107 c.NodePort = port
108 } else if c.NodePort == "" {
109 c.NodePort = defaultPort
110 }
111
112 chainType := os.Getenv(envChainType)
113 if chainType != "" {
114 c.ChainType = chainType
115 } else if c.ChainType == "" {
116 c.ChainType = defaultChainType
117 }
118
119 gethIP := os.Getenv(envGethPool)
120 if gethIP != "" {
121 nodeList := make(map[string]bool)
122 for _, ethNode := range c.ChainNodePool {
123 nodeList[ethNode] = true
124 }
125 ipPool := strings.Split(gethIP, ",")
126 for _, ip := range ipPool {
127 if !nodeList[ip] {
128 c.ChainNodePool = append(c.ChainNodePool, ip)
129 }
130 }
131 }
132 return
133}
134
135// UpdateConfig saves configuration to a file.
136func (c *Config) UpdateConfig() (err error) {

Callers 1

LoadConfigMethod · 0.95

Calls 1

NewMethod · 0.65

Tested by

no test coverage detected