support cli flag

pull/3853/head
Lutty 3 years ago
parent d58243b630
commit 5221838f26
  1. 1
      cmd/harmony/default.go
  2. 12
      cmd/harmony/flags.go
  3. 1
      cmd/harmony/main.go
  4. 1
      internal/configs/harmony/harmony.go
  5. 10
      internal/configs/node/network.go

@ -34,6 +34,7 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
RosettaEnabled: false,
IP: "127.0.0.1",
Port: nodeconfig.DefaultRPCPort,
AuthPort: nodeconfig.DefaultAuthRPCPort,
RosettaPort: nodeconfig.DefaultRosettaPort,
},
WS: harmonyconfig.WsConfig{

@ -64,6 +64,7 @@ var (
httpRosettaEnabledFlag,
httpIPFlag,
httpPortFlag,
httpAuthPortFlag,
httpRosettaPortFlag,
}
@ -568,6 +569,11 @@ var (
Usage: "rpc port to listen for HTTP requests",
DefValue: defaultConfig.HTTP.Port,
}
httpAuthPortFlag = cli.IntFlag{
Name: "http.auth-port",
Usage: "rpc port to listen for auth HTTP requests",
DefValue: defaultConfig.HTTP.AuthPort,
}
httpRosettaEnabledFlag = cli.BoolFlag{
Name: "http.rosetta",
Usage: "enable HTTP / Rosetta requests",
@ -593,6 +599,11 @@ func applyHTTPFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
isRPCSpecified = true
}
if cli.IsFlagChanged(cmd, httpAuthPortFlag) {
config.HTTP.AuthPort = cli.GetIntFlagValue(cmd, httpAuthPortFlag)
isRPCSpecified = true
}
if cli.IsFlagChanged(cmd, httpRosettaPortFlag) {
config.HTTP.RosettaPort = cli.GetIntFlagValue(cmd, httpRosettaPortFlag)
isRosettaSpecified = true
@ -1336,6 +1347,7 @@ func applyLegacyMiscFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfi
legacyPort := cli.GetIntFlagValue(cmd, legacyPortFlag)
config.P2P.Port = legacyPort
config.HTTP.Port = nodeconfig.GetRPCHTTPPortFromBase(legacyPort)
config.HTTP.AuthPort = nodeconfig.GetRPCAuthHTTPPortFromBase(legacyPort)
config.HTTP.RosettaPort = nodeconfig.GetRosettaHTTPPortFromBase(legacyPort)
config.WS.Port = nodeconfig.GetWSPortFromBase(legacyPort)

@ -313,6 +313,7 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) {
HTTPEnabled: hc.HTTP.Enabled,
HTTPIp: hc.HTTP.IP,
HTTPPort: hc.HTTP.Port,
HTTPAuthPort: hc.HTTP.AuthPort,
WSEnabled: hc.WS.Enabled,
WSIp: hc.WS.IP,
WSPort: hc.WS.Port,

@ -136,6 +136,7 @@ type HttpConfig struct {
Enabled bool
IP string
Port int
AuthPort int
RosettaEnabled bool
RosettaPort int
}

@ -48,6 +48,8 @@ const (
DefaultDNSPort = 6000
// DefaultRPCPort is the default rpc port. The actual port used is 9000+500
DefaultRPCPort = 9500
// DefaultAuthRPCPort is the default rpc auth port. The actual port used is 9000+501
DefaultAuthRPCPort = 9501
// DefaultRosettaPort is the default rosetta port. The actual port used is 9000+700
DefaultRosettaPort = 9700
// DefaultWSPort is the default port for web socket endpoint. The actual port used is
@ -67,6 +69,9 @@ const (
// rpcHTTPPortOffset is the port offset for RPC HTTP requests
rpcHTTPPortOffset = 500
// rpcHTTPAuthPortOffset is the port offset for RPC Auth HTTP requests
rpcHTTPAuthPortOffset = 501
// rpcHTTPPortOffset is the port offset for rosetta HTTP requests
rosettaHTTPPortOffset = 700
@ -123,6 +128,11 @@ func GetRPCHTTPPortFromBase(basePort int) int {
return basePort + rpcHTTPPortOffset
}
// GetRPCAuthHTTPPortFromBase return the rpc HTTP port from base port
func GetRPCAuthHTTPPortFromBase(basePort int) int {
return basePort + rpcHTTPAuthPortOffset
}
// GetRosettaHTTPPortFromBase return the rosetta HTTP port from base port
func GetRosettaHTTPPortFromBase(basePort int) int {
return basePort + rosettaHTTPPortOffset

Loading…
Cancel
Save