Skip to content

Commit

Permalink
feat: change flag name
Browse files Browse the repository at this point in the history
  • Loading branch information
fearlessfe committed Mar 17, 2024
1 parent eaaf65e commit ccfd265
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions cmd/shisui/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
)

func TestGenConfig(t *testing.T) {
size := uint64(1000 * 1000)
size := uint64(5 * 1000 * 1000 * 1000)
flagSet := flag.NewFlagSet("test", 0)
flagSet.String("history.http.addr", "127.0.0.11", "test")
flagSet.String("history.http.port", "8888", "test")
flagSet.String("history.data.dir", "./test", "test")
flagSet.Uint64("history.data.capacity", size, "test")
flagSet.String("rpc.addr", "127.0.0.11", "test")
flagSet.String("rpc.port", "8888", "test")
flagSet.String("data.dir", "./test", "test")
flagSet.Uint64("data.capacity", size, "test")
flagSet.String("udp.addr", "172.23.50.11", "test")
flagSet.Int("udp.port", 9999, "test")
flagSet.Int("history.loglevel", 3, "test")
flagSet.Int("loglevel", 3, "test")

command := &cli.Command{Name: "mycommand"}

Expand Down
30 changes: 15 additions & 15 deletions cmd/shisui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ var app = flags.NewApp("the go-portal-network command line interface")

var (
portalProtocolFlags = []cli.Flag{
utils.ProtocolUDPListenAddrFlag,
utils.ProtocolUDPPortFlag,
utils.PortalUDPListenAddrFlag,
utils.PortalUDPPortFlag,
}
historyRpcFlags = []cli.Flag{
utils.HistoryHTTPListenAddrFlag,
utils.HistoryHTTPPortFlag,
utils.HistoryDataDirFlag,
utils.HistoryDataCapacityFlag,
utils.LogLevelFlag,
utils.PortalRPCListenAddrFlag,
utils.PortalRPCPortFlag,
utils.PortalDataDirFlag,
utils.PortalDataCapacityFlag,
utils.PortalLogLevelFlag,
}
hiveTestFlags = []cli.Flag{
utils.HiveBootNodeFlag,
Expand Down Expand Up @@ -118,21 +118,21 @@ func getPortalHistoryConfig(ctx *cli.Context) (*PortalHistoryConfig, error) {
return config, err
}

httpAddr := ctx.String(utils.HistoryHTTPListenAddrFlag.Name)
httpPort := ctx.String(utils.HistoryHTTPPortFlag.Name)
httpAddr := ctx.String(utils.PortalRPCListenAddrFlag.Name)
httpPort := ctx.String(utils.PortalRPCPortFlag.Name)
config.RpcAddr = net.JoinHostPort(httpAddr, httpPort)
config.DataDir = ctx.String(utils.HistoryDataDirFlag.Name)
config.DataCapacity = ctx.Uint64(utils.HistoryDataCapacityFlag.Name)
config.LogLevel = ctx.Int(utils.LogLevelFlag.Name)
port := ctx.String(utils.ProtocolUDPPortFlag.Name)
config.DataDir = ctx.String(utils.PortalDataDirFlag.Name)
config.DataCapacity = ctx.Uint64(utils.PortalDataCapacityFlag.Name)
config.LogLevel = ctx.Int(utils.PortalLogLevelFlag.Name)
port := ctx.String(utils.PortalUDPPortFlag.Name)
if !strings.HasPrefix(port, ":") {
config.Protocol.ListenAddr = ":" + port
} else {
config.Protocol.ListenAddr = port
}

if ctx.IsSet(utils.ProtocolUDPListenAddrFlag.Name) {
ip := ctx.String(utils.ProtocolUDPListenAddrFlag.Name)
if ctx.IsSet(utils.PortalUDPListenAddrFlag.Name) {
ip := ctx.String(utils.PortalUDPListenAddrFlag.Name)
netIp := net.ParseIP(ip)
if netIp == nil {
return config, fmt.Errorf("invalid ip addr: %s", ip)
Expand Down
26 changes: 13 additions & 13 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,50 +945,50 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Category: flags.MetricsCategory,
}

HistoryHTTPListenAddrFlag = &cli.StringFlag{
Name: "history.http.addr",
PortalRPCListenAddrFlag = &cli.StringFlag{
Name: "rpc.addr",
Usage: "HTTP-RPC server listening interface",
Value: node.DefaultHTTPHost,
Category: flags.PortalNetworkCategory,
}

HistoryHTTPPortFlag = &cli.IntFlag{
Name: "history.http.port",
PortalRPCPortFlag = &cli.IntFlag{
Name: "rpc.port",
Usage: "HTTP-RPC server listening port",
Value: node.DefaultHTTPPort,
Category: flags.PortalNetworkCategory,
}

HistoryDataDirFlag = &cli.StringFlag{
Name: "history.data.dir",
PortalDataDirFlag = &cli.StringFlag{
Name: "data.dir",
Usage: "data dir of where the data file located",
Value: "./",
Category: flags.PortalNetworkCategory,
}

HistoryDataCapacityFlag = &cli.Uint64Flag{
Name: "history.data.capacity",
PortalDataCapacityFlag = &cli.Uint64Flag{
Name: "data.capacity",
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,
}

ProtocolUDPListenAddrFlag = &cli.StringFlag{
PortalUDPListenAddrFlag = &cli.StringFlag{
Name: "udp.addr",
Usage: "protocol UDP server listening interface",
Value: "",
Category: flags.PortalNetworkCategory,
}

ProtocolUDPPortFlag = &cli.IntFlag{
PortalUDPPortFlag = &cli.IntFlag{
Name: "udp.port",
Usage: "protocol UDP server listening port",
Value: node.DefaultUDPPort,
Category: flags.PortalNetworkCategory,
}

LogLevelFlag = &cli.IntFlag{
Name: "history.loglevel",
PortalLogLevelFlag = &cli.IntFlag{
Name: "loglevel",
Usage: "loglevel of portal network",
Value: node.DetaultLoglevel,
Category: flags.PortalNetworkCategory,
Expand Down

0 comments on commit ccfd265

Please sign in to comment.