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, RosettaEnabled: false,
IP: "127.0.0.1", IP: "127.0.0.1",
Port: nodeconfig.DefaultRPCPort, Port: nodeconfig.DefaultRPCPort,
AuthPort: nodeconfig.DefaultAuthRPCPort,
RosettaPort: nodeconfig.DefaultRosettaPort, RosettaPort: nodeconfig.DefaultRosettaPort,
}, },
WS: harmonyconfig.WsConfig{ WS: harmonyconfig.WsConfig{

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

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

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

@ -48,6 +48,8 @@ const (
DefaultDNSPort = 6000 DefaultDNSPort = 6000
// DefaultRPCPort is the default rpc port. The actual port used is 9000+500 // DefaultRPCPort is the default rpc port. The actual port used is 9000+500
DefaultRPCPort = 9500 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 is the default rosetta port. The actual port used is 9000+700
DefaultRosettaPort = 9700 DefaultRosettaPort = 9700
// DefaultWSPort is the default port for web socket endpoint. The actual port used is // 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 is the port offset for RPC HTTP requests
rpcHTTPPortOffset = 500 rpcHTTPPortOffset = 500
// rpcHTTPAuthPortOffset is the port offset for RPC Auth HTTP requests
rpcHTTPAuthPortOffset = 501
// rpcHTTPPortOffset is the port offset for rosetta HTTP requests // rpcHTTPPortOffset is the port offset for rosetta HTTP requests
rosettaHTTPPortOffset = 700 rosettaHTTPPortOffset = 700
@ -123,6 +128,11 @@ func GetRPCHTTPPortFromBase(basePort int) int {
return basePort + rpcHTTPPortOffset 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 // GetRosettaHTTPPortFromBase return the rosetta HTTP port from base port
func GetRosettaHTTPPortFromBase(basePort int) int { func GetRosettaHTTPPortFromBase(basePort int) int {
return basePort + rosettaHTTPPortOffset return basePort + rosettaHTTPPortOffset

Loading…
Cancel
Save