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

@ -56,27 +56,15 @@ func (role Role) String() string {
} }
// NetworkType describes the type of Harmony network // NetworkType describes the type of Harmony network
type NetworkType int type NetworkType string
// Constants for NetworkType // Constants for NetworkType
const ( const (
Mainnet NetworkType = iota Mainnet = "mainnet"
Testnet Testnet = "testnet"
Devnet 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 // Network is the type of Harmony network
var Network = Testnet var Network = Testnet

Loading…
Cancel
Save