move constants to nodeconfig

pull/1142/head
Minh Doan 6 years ago committed by Minh Doan
parent d558438966
commit 6674669ebb
  1. 14
      cmd/harmony/main.go
  2. 20
      internal/configs/node/config.go

@ -139,12 +139,6 @@ var (
"Do not propose view change (testing only)")
)
const (
MainNet = "mainnet"
TestNet = "testnet"
DevNet = "devnet"
)
func initSetup() {
// Set port and ip to global config.
nodeconfig.GetDefaultConfig().Port = *port
@ -260,11 +254,11 @@ func createGlobalConfig() *nodeconfig.ConfigType {
// Set network type
switch *networkType {
case MainNet:
case nodeconfig.Mainnet:
nodeConfig.SetNetworkType(nodeconfig.Mainnet)
case TestNet:
case nodeconfig.Testnet:
nodeConfig.SetNetworkType(nodeconfig.Testnet)
case DevNet:
case nodeconfig.Devnet:
nodeConfig.SetNetworkType(nodeconfig.Devnet)
default:
panic(fmt.Sprintf("invalid network type: %s", *networkType))
@ -495,7 +489,7 @@ func main() {
currentNode.ServiceManagerSetup()
// RPC for SDK not supported for mainnet.
if *networkType != MainNet {
if *networkType != nodeconfig.Mainnet {
if err := currentNode.StartRPC(*port); err != nil {
ctxerror.Warn(utils.GetLogger(), err, "StartRPC failed")
}

@ -56,27 +56,15 @@ func (role Role) String() string {
}
// NetworkType describes the type of Harmony network
type NetworkType int
type NetworkType string
// Constants for NetworkType
const (
Mainnet NetworkType = iota
Testnet
Devnet
Mainnet = "mainnet"
Testnet = "testnet"
Devnet = "devnet"
)
func (network NetworkType) String() string {
switch network {
case Mainnet:
return "Mainnet"
case Testnet:
return "Testnet"
case Devnet:
return "Devnet"
}
return "Unknown"
}
// Network is the type of Harmony network
var Network = Testnet

Loading…
Cancel
Save