Skip to content

Commit 3ea2de8

Browse files
authored
Merge pull request #855 from gzliudan/modify_flag_value
cmd/utils: change default value of some flags to simplify sync
2 parents ede4c10 + bea5c95 commit 3ea2de8

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

cmd/XDC/consolecmd_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestHTTPAttachWelcome(t *testing.T) {
101101
XDC := runXDC(t,
102102
"--datadir", datadir, "--XDCx-datadir", datadir+"/XDCx",
103103
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
104-
"--miner-etherbase", coinbase, "--http", "--http-port", port)
104+
"--miner-etherbase", coinbase, "--http", "--http-port", port, "--http-api", "eth,net,rpc,web3")
105105

106106
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
107107
testAttachWelcome(t, XDC, "http://localhost:"+port, httpAPIs)
@@ -117,7 +117,7 @@ func TestWSAttachWelcome(t *testing.T) {
117117
XDC := runXDC(t,
118118
"--datadir", datadir, "--XDCx-datadir", datadir+"/XDCx",
119119
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
120-
"--miner-etherbase", coinbase, "--ws", "--ws-port", port)
120+
"--miner-etherbase", coinbase, "--ws", "--ws-port", port, "--ws-api", "eth,net,rpc,web3")
121121

122122
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
123123
testAttachWelcome(t, XDC, "ws://localhost:"+port, httpAPIs)

cmd/utils/flags.go

+28-36
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,21 @@ var (
345345
Name: "miner-gaslimit",
346346
Aliases: []string{"targetgaslimit"},
347347
Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
348-
Value: params.XDCGenesisGasLimit,
348+
Value: 50000000,
349349
Category: flags.MinerCategory,
350350
}
351351
MinerGasPriceFlag = &flags.BigFlag{
352352
Name: "miner-gasprice",
353353
Aliases: []string{"gasprice"},
354354
Usage: "Minimal gas price to accept for mining a transactions",
355-
Value: ethconfig.Defaults.GasPrice,
355+
Value: big.NewInt(1),
356356
Category: flags.MinerCategory,
357357
}
358358
MinerEtherbaseFlag = &cli.StringFlag{
359359
Name: "miner-etherbase",
360360
Aliases: []string{"etherbase"},
361361
Usage: "Public address for block mining rewards (default = first account created)",
362-
Value: "0",
362+
Value: "0x000000000000000000000000000000000000abcd",
363363
Category: flags.MinerCategory,
364364
}
365365
MinerExtraDataFlag = &cli.StringFlag{
@@ -437,13 +437,14 @@ var (
437437
Name: "http",
438438
Aliases: []string{"rpc"},
439439
Usage: "Enable the HTTP-RPC server",
440+
Value: true,
440441
Category: flags.APICategory,
441442
}
442443
HTTPListenAddrFlag = &cli.StringFlag{
443444
Name: "http-addr",
444445
Aliases: []string{"rpcaddr"},
445446
Usage: "HTTP-RPC server listening interface",
446-
Value: node.DefaultHTTPHost,
447+
Value: "0.0.0.0",
447448
Category: flags.APICategory,
448449
}
449450
HTTPPortFlag = &cli.IntFlag{
@@ -457,21 +458,21 @@ var (
457458
Name: "http-corsdomain",
458459
Aliases: []string{"rpccorsdomain"},
459460
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
460-
Value: "",
461+
Value: "*",
461462
Category: flags.APICategory,
462463
}
463464
HTTPVirtualHostsFlag = &cli.StringFlag{
464465
Name: "http-vhosts",
465466
Aliases: []string{"rpcvhosts"},
466467
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
467-
Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
468+
Value: "*",
468469
Category: flags.APICategory,
469470
}
470471
HTTPApiFlag = &cli.StringFlag{
471472
Name: "http-api",
472473
Aliases: []string{"rpcapi"},
473474
Usage: "API's offered over the HTTP-RPC interface",
474-
Value: "",
475+
Value: "debug,eth,net,personal,txpool,web3,XDPoS",
475476
Category: flags.APICategory,
476477
}
477478
HTTPReadTimeoutFlag = &cli.DurationFlag{
@@ -498,13 +499,14 @@ var (
498499
WSEnabledFlag = &cli.BoolFlag{
499500
Name: "ws",
500501
Usage: "Enable the WS-RPC server",
502+
Value: true,
501503
Category: flags.APICategory,
502504
}
503505
WSListenAddrFlag = &cli.StringFlag{
504506
Name: "ws-addr",
505507
Aliases: []string{"wsaddr"},
506508
Usage: "WS-RPC server listening interface",
507-
Value: node.DefaultWSHost,
509+
Value: "0.0.0.0",
508510
Category: flags.APICategory,
509511
}
510512
WSPortFlag = &cli.IntFlag{
@@ -518,14 +520,14 @@ var (
518520
Name: "ws-api",
519521
Aliases: []string{"wsapi"},
520522
Usage: "API's offered over the WS-RPC interface",
521-
Value: "",
523+
Value: "debug,eth,net,personal,txpool,web3,XDPoS",
522524
Category: flags.APICategory,
523525
}
524526
WSAllowedOriginsFlag = &cli.StringFlag{
525527
Name: "ws-origins",
526528
Aliases: []string{"wsorigins"},
527529
Usage: "Origins from which to accept websockets requests",
528-
Value: "",
530+
Value: "*",
529531
Category: flags.APICategory,
530532
}
531533
ExecFlag = &cli.StringFlag{
@@ -970,11 +972,11 @@ func splitAndTrim(input string) (ret []string) {
970972
// setHTTP creates the HTTP RPC listener interface string from the set
971973
// command line flags, returning empty if the HTTP endpoint is disabled.
972974
func setHTTP(ctx *cli.Context, cfg *node.Config) {
973-
if ctx.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" {
974-
cfg.HTTPHost = "127.0.0.1"
975-
if ctx.IsSet(HTTPListenAddrFlag.Name) {
976-
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
975+
if ctx.Bool(HTTPEnabledFlag.Name) {
976+
if cfg.HTTPHost == "" {
977+
cfg.HTTPHost = "127.0.0.1"
977978
}
979+
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
978980
}
979981

980982
if ctx.IsSet(HTTPPortFlag.Name) {
@@ -989,36 +991,26 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
989991
if ctx.IsSet(HTTPIdleTimeoutFlag.Name) {
990992
cfg.HTTPTimeouts.IdleTimeout = ctx.Duration(HTTPIdleTimeoutFlag.Name)
991993
}
992-
if ctx.IsSet(HTTPCORSDomainFlag.Name) {
993-
cfg.HTTPCors = splitAndTrim(ctx.String(HTTPCORSDomainFlag.Name))
994-
}
995-
if ctx.IsSet(HTTPApiFlag.Name) {
996-
cfg.HTTPModules = splitAndTrim(ctx.String(HTTPApiFlag.Name))
997-
}
998-
if ctx.IsSet(HTTPVirtualHostsFlag.Name) {
999-
cfg.HTTPVirtualHosts = splitAndTrim(ctx.String(HTTPVirtualHostsFlag.Name))
1000-
}
994+
cfg.HTTPCors = splitAndTrim(ctx.String(HTTPCORSDomainFlag.Name))
995+
cfg.HTTPModules = splitAndTrim(ctx.String(HTTPApiFlag.Name))
996+
cfg.HTTPVirtualHosts = splitAndTrim(ctx.String(HTTPVirtualHostsFlag.Name))
1001997
}
1002998

1003999
// setWS creates the WebSocket RPC listener interface string from the set
10041000
// command line flags, returning empty if the HTTP endpoint is disabled.
10051001
func setWS(ctx *cli.Context, cfg *node.Config) {
1006-
if ctx.Bool(WSEnabledFlag.Name) && cfg.WSHost == "" {
1007-
cfg.WSHost = "127.0.0.1"
1008-
if ctx.IsSet(WSListenAddrFlag.Name) {
1009-
cfg.WSHost = ctx.String(WSListenAddrFlag.Name)
1002+
if ctx.Bool(WSEnabledFlag.Name) {
1003+
if cfg.WSHost == "" {
1004+
cfg.WSHost = "127.0.0.1"
10101005
}
1006+
cfg.WSHost = ctx.String(WSListenAddrFlag.Name)
10111007
}
10121008

10131009
if ctx.IsSet(WSPortFlag.Name) {
10141010
cfg.WSPort = ctx.Int(WSPortFlag.Name)
10151011
}
1016-
if ctx.IsSet(WSAllowedOriginsFlag.Name) {
1017-
cfg.WSOrigins = splitAndTrim(ctx.String(WSAllowedOriginsFlag.Name))
1018-
}
1019-
if ctx.IsSet(WSApiFlag.Name) {
1020-
cfg.WSModules = splitAndTrim(ctx.String(WSApiFlag.Name))
1021-
}
1012+
cfg.WSOrigins = splitAndTrim(ctx.String(WSAllowedOriginsFlag.Name))
1013+
cfg.WSModules = splitAndTrim(ctx.String(WSApiFlag.Name))
10221014
}
10231015

10241016
// setIPC creates an IPC path configuration from the set command line flags,
@@ -1098,6 +1090,8 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *ethconfig.Config
10981090
Fatalf("Option %q: %v", MinerEtherbaseFlag.Name, err)
10991091
}
11001092
cfg.Etherbase = account.Address
1093+
} else {
1094+
cfg.Etherbase = common.HexToAddress(ctx.String(MinerEtherbaseFlag.Name))
11011095
}
11021096
}
11031097

@@ -1482,9 +1476,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
14821476
if ctx.IsSet(MinerExtraDataFlag.Name) {
14831477
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
14841478
}
1485-
if ctx.IsSet(MinerGasPriceFlag.Name) {
1486-
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
1487-
}
1479+
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
14881480
if ctx.IsSet(CacheLogSizeFlag.Name) {
14891481
cfg.FilterLogCacheSize = ctx.Int(CacheLogSizeFlag.Name)
14901482
}

0 commit comments

Comments
 (0)