feat: change flag name

This commit is contained in:
fearlessfe 2024-03-17 10:26:29 +08:00 committed by Chen Kai
parent 2b6c5eb292
commit afeaa102b4
3 changed files with 34 additions and 34 deletions

View file

@ -9,15 +9,15 @@ import (
) )
func TestGenConfig(t *testing.T) { func TestGenConfig(t *testing.T) {
size := uint64(1000 * 1000) size := uint64(5 * 1000 * 1000 * 1000)
flagSet := flag.NewFlagSet("test", 0) flagSet := flag.NewFlagSet("test", 0)
flagSet.String("history.http.addr", "127.0.0.11", "test") flagSet.String("rpc.addr", "127.0.0.11", "test")
flagSet.String("history.http.port", "8888", "test") flagSet.String("rpc.port", "8888", "test")
flagSet.String("history.data.dir", "./test", "test") flagSet.String("data.dir", "./test", "test")
flagSet.Uint64("history.data.capacity", size, "test") flagSet.Uint64("data.capacity", size, "test")
flagSet.String("udp.addr", "172.23.50.11", "test") flagSet.String("udp.addr", "172.23.50.11", "test")
flagSet.Int("udp.port", 9999, "test") flagSet.Int("udp.port", 9999, "test")
flagSet.Int("history.loglevel", 3, "test") flagSet.Int("loglevel", 3, "test")
command := &cli.Command{Name: "mycommand"} command := &cli.Command{Name: "mycommand"}

View file

@ -34,15 +34,15 @@ var app = flags.NewApp("the go-portal-network command line interface")
var ( var (
portalProtocolFlags = []cli.Flag{ portalProtocolFlags = []cli.Flag{
utils.ProtocolUDPListenAddrFlag, utils.PortalUDPListenAddrFlag,
utils.ProtocolUDPPortFlag, utils.PortalUDPPortFlag,
} }
historyRpcFlags = []cli.Flag{ historyRpcFlags = []cli.Flag{
utils.HistoryHTTPListenAddrFlag, utils.PortalRPCListenAddrFlag,
utils.HistoryHTTPPortFlag, utils.PortalRPCPortFlag,
utils.HistoryDataDirFlag, utils.PortalDataDirFlag,
utils.HistoryDataCapacityFlag, utils.PortalDataCapacityFlag,
utils.LogLevelFlag, utils.PortalLogLevelFlag,
} }
hiveTestFlags = []cli.Flag{ hiveTestFlags = []cli.Flag{
utils.HiveBootNodeFlag, utils.HiveBootNodeFlag,
@ -118,21 +118,21 @@ func getPortalHistoryConfig(ctx *cli.Context) (*PortalHistoryConfig, error) {
return config, err return config, err
} }
httpAddr := ctx.String(utils.HistoryHTTPListenAddrFlag.Name) httpAddr := ctx.String(utils.PortalRPCListenAddrFlag.Name)
httpPort := ctx.String(utils.HistoryHTTPPortFlag.Name) httpPort := ctx.String(utils.PortalRPCPortFlag.Name)
config.RpcAddr = net.JoinHostPort(httpAddr, httpPort) config.RpcAddr = net.JoinHostPort(httpAddr, httpPort)
config.DataDir = ctx.String(utils.HistoryDataDirFlag.Name) config.DataDir = ctx.String(utils.PortalDataDirFlag.Name)
config.DataCapacity = ctx.Uint64(utils.HistoryDataCapacityFlag.Name) config.DataCapacity = ctx.Uint64(utils.PortalDataCapacityFlag.Name)
config.LogLevel = ctx.Int(utils.LogLevelFlag.Name) config.LogLevel = ctx.Int(utils.PortalLogLevelFlag.Name)
port := ctx.String(utils.ProtocolUDPPortFlag.Name) port := ctx.String(utils.PortalUDPPortFlag.Name)
if !strings.HasPrefix(port, ":") { if !strings.HasPrefix(port, ":") {
config.Protocol.ListenAddr = ":" + port config.Protocol.ListenAddr = ":" + port
} else { } else {
config.Protocol.ListenAddr = port config.Protocol.ListenAddr = port
} }
if ctx.IsSet(utils.ProtocolUDPListenAddrFlag.Name) { if ctx.IsSet(utils.PortalUDPListenAddrFlag.Name) {
ip := ctx.String(utils.ProtocolUDPListenAddrFlag.Name) ip := ctx.String(utils.PortalUDPListenAddrFlag.Name)
netIp := net.ParseIP(ip) netIp := net.ParseIP(ip)
if netIp == nil { if netIp == nil {
return config, fmt.Errorf("invalid ip addr: %s", ip) return config, fmt.Errorf("invalid ip addr: %s", ip)

View file

@ -945,50 +945,50 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Category: flags.MetricsCategory, Category: flags.MetricsCategory,
} }
HistoryHTTPListenAddrFlag = &cli.StringFlag{ PortalRPCListenAddrFlag = &cli.StringFlag{
Name: "history.http.addr", Name: "rpc.addr",
Usage: "HTTP-RPC server listening interface", Usage: "HTTP-RPC server listening interface",
Value: node.DefaultHTTPHost, Value: node.DefaultHTTPHost,
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
HistoryHTTPPortFlag = &cli.IntFlag{ PortalRPCPortFlag = &cli.IntFlag{
Name: "history.http.port", Name: "rpc.port",
Usage: "HTTP-RPC server listening port", Usage: "HTTP-RPC server listening port",
Value: node.DefaultHTTPPort, Value: node.DefaultHTTPPort,
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
HistoryDataDirFlag = &cli.StringFlag{ PortalDataDirFlag = &cli.StringFlag{
Name: "history.data.dir", Name: "data.dir",
Usage: "data dir of where the data file located", Usage: "data dir of where the data file located",
Value: "./", Value: "./",
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
HistoryDataCapacityFlag = &cli.Uint64Flag{ PortalDataCapacityFlag = &cli.Uint64Flag{
Name: "history.data.capacity", Name: "data.capacity",
Usage: "the capacity of the data stored, the unit is byte", Usage: "the capacity of the data stored, the unit is byte",
Value: 1000 * 1000 * 1000, // 1 GB Value: 1000 * 1000 * 1000 * 2, // 2 GB
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
ProtocolUDPListenAddrFlag = &cli.StringFlag{ PortalUDPListenAddrFlag = &cli.StringFlag{
Name: "udp.addr", Name: "udp.addr",
Usage: "protocol UDP server listening interface", Usage: "protocol UDP server listening interface",
Value: "", Value: "",
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
ProtocolUDPPortFlag = &cli.IntFlag{ PortalUDPPortFlag = &cli.IntFlag{
Name: "udp.port", Name: "udp.port",
Usage: "protocol UDP server listening port", Usage: "protocol UDP server listening port",
Value: node.DefaultUDPPort, Value: node.DefaultUDPPort,
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,
} }
LogLevelFlag = &cli.IntFlag{ PortalLogLevelFlag = &cli.IntFlag{
Name: "history.loglevel", Name: "loglevel",
Usage: "loglevel of portal network", Usage: "loglevel of portal network",
Value: node.DetaultLoglevel, Value: node.DetaultLoglevel,
Category: flags.PortalNetworkCategory, Category: flags.PortalNetworkCategory,