aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-07-10 13:54:06 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-07-10 14:12:07 +0800
commitc705aac826ca41744f303b9adb239f1e09bff86e (patch)
treedcadfcb37f5405865f5f83031ccd2edcdc35ae56
parentc6a9616cfdeca0cdbc01686750437a76b0e7d485 (diff)
downloadgo-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar.gz
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar.bz2
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar.lz
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar.xz
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.tar.zst
go-tangerine-c705aac826ca41744f303b9adb239f1e09bff86e.zip
cmd, eth, les: make les flags conform to dotted style
-rw-r--r--cmd/geth/main.go12
-rw-r--r--cmd/geth/usage.go12
-rw-r--r--cmd/utils/flags.go75
-rw-r--r--eth/config.go8
-rw-r--r--eth/gen_config.go20
-rw-r--r--les/costtracker.go8
6 files changed, 79 insertions, 56 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 4d0dc14da..7d30c9243 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -93,10 +93,12 @@ var (
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
utils.GCModeFlag,
- utils.LightServFlag,
- utils.LightBandwidthInFlag,
- utils.LightBandwidthOutFlag,
- utils.LightPeersFlag,
+ utils.LightServeFlag,
+ utils.LightLegacyServFlag,
+ utils.LightIngressFlag,
+ utils.LightEgressFlag,
+ utils.LightMaxPeersFlag,
+ utils.LightLegacyPeersFlag,
utils.LightKDFFlag,
utils.UltraLightServersFlag,
utils.UltraLightFractionFlag,
@@ -336,7 +338,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Set contract backend for ethereum service if local node
// is serving LES requests.
- if ctx.GlobalInt(utils.LightServFlag.Name) > 0 {
+ if ctx.GlobalInt(utils.LightLegacyServFlag.Name) > 0 || ctx.GlobalInt(utils.LightServeFlag.Name) > 0 {
var ethService *eth.Ethereum
if err := stack.Service(&ethService); err != nil {
utils.Fatalf("Failed to retrieve ethereum service: %v", err)
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 1b40f76a4..af195425b 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -87,12 +87,12 @@ var AppHelpFlagGroups = []flagGroup{
},
},
{
- Name: "LES",
+ Name: "LIGHT CLIENT",
Flags: []cli.Flag{
- utils.LightServFlag,
- utils.LightBandwidthInFlag,
- utils.LightBandwidthOutFlag,
- utils.LightPeersFlag,
+ utils.LightServeFlag,
+ utils.LightIngressFlag,
+ utils.LightEgressFlag,
+ utils.LightMaxPeersFlag,
utils.UltraLightServersFlag,
utils.UltraLightFractionFlag,
utils.UltraLightOnlyAnnounceFlag,
@@ -253,6 +253,8 @@ var AppHelpFlagGroups = []flagGroup{
{
Name: "DEPRECATED",
Flags: []cli.Flag{
+ utils.LightLegacyServFlag,
+ utils.LightLegacyPeersFlag,
utils.MinerLegacyThreadsFlag,
utils.MinerLegacyGasTargetFlag,
utils.MinerLegacyGasPriceFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 8fff0baf4..27dbb7313 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -209,25 +209,35 @@ var (
Name: "whitelist",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
}
- // LES settings
- LightServFlag = cli.IntFlag{
+ // Light server and client settings
+ LightLegacyServFlag = cli.IntFlag{ // Deprecated in favor of light.serve, remove in 2021
Name: "lightserv",
+ Usage: "Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)",
+ Value: eth.DefaultConfig.LightServ,
+ }
+ LightServeFlag = cli.IntFlag{
+ Name: "light.serve",
Usage: "Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)",
- Value: 0,
+ Value: eth.DefaultConfig.LightServ,
}
- LightBandwidthInFlag = cli.IntFlag{
- Name: "lightbwin",
- Usage: "Incoming bandwidth limit for light server (kilobytes/sec, 0 = unlimited)",
- Value: 0,
+ LightIngressFlag = cli.IntFlag{
+ Name: "light.ingress",
+ Usage: "Incoming bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
+ Value: eth.DefaultConfig.LightIngress,
}
- LightBandwidthOutFlag = cli.IntFlag{
- Name: "lightbwout",
- Usage: "Outgoing bandwidth limit for light server (kilobytes/sec, 0 = unlimited)",
- Value: 0,
+ LightEgressFlag = cli.IntFlag{
+ Name: "light.egress",
+ Usage: "Outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
+ Value: eth.DefaultConfig.LightEgress,
}
- LightPeersFlag = cli.IntFlag{
+ LightLegacyPeersFlag = cli.IntFlag{ // Deprecated in favor of light.maxpeers, remove in 2021
Name: "lightpeers",
- Usage: "Maximum number of LES client peers",
+ Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)",
+ Value: eth.DefaultConfig.LightPeers,
+ }
+ LightMaxPeersFlag = cli.IntFlag{
+ Name: "light.maxpeers",
+ Usage: "Maximum number of light clients to serve, or light servers to attach to",
Value: eth.DefaultConfig.LightPeers,
}
UltraLightServersFlag = cli.StringFlag{
@@ -952,17 +962,23 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
// setLes configures the les server and ultra light client settings from the command line flags.
func setLes(ctx *cli.Context, cfg *eth.Config) {
- if ctx.GlobalIsSet(LightServFlag.Name) {
- cfg.LightServ = ctx.GlobalInt(LightServFlag.Name)
+ if ctx.GlobalIsSet(LightLegacyServFlag.Name) {
+ cfg.LightServ = ctx.GlobalInt(LightLegacyServFlag.Name)
+ }
+ if ctx.GlobalIsSet(LightServeFlag.Name) {
+ cfg.LightServ = ctx.GlobalInt(LightServeFlag.Name)
+ }
+ if ctx.GlobalIsSet(LightIngressFlag.Name) {
+ cfg.LightIngress = ctx.GlobalInt(LightIngressFlag.Name)
}
- if ctx.GlobalIsSet(LightBandwidthInFlag.Name) {
- cfg.LightBandwidthIn = ctx.GlobalInt(LightBandwidthInFlag.Name)
+ if ctx.GlobalIsSet(LightEgressFlag.Name) {
+ cfg.LightEgress = ctx.GlobalInt(LightEgressFlag.Name)
}
- if ctx.GlobalIsSet(LightBandwidthOutFlag.Name) {
- cfg.LightBandwidthOut = ctx.GlobalInt(LightBandwidthOutFlag.Name)
+ if ctx.GlobalIsSet(LightLegacyPeersFlag.Name) {
+ cfg.LightPeers = ctx.GlobalInt(LightLegacyPeersFlag.Name)
}
- if ctx.GlobalIsSet(LightPeersFlag.Name) {
- cfg.LightPeers = ctx.GlobalInt(LightPeersFlag.Name)
+ if ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
+ cfg.LightPeers = ctx.GlobalInt(LightMaxPeersFlag.Name)
}
if ctx.GlobalIsSet(UltraLightServersFlag.Name) {
cfg.UltraLightServers = strings.Split(ctx.GlobalString(UltraLightServersFlag.Name), ",")
@@ -1069,19 +1085,22 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
setBootstrapNodesV5(ctx, cfg)
lightClient := ctx.GlobalString(SyncModeFlag.Name) == "light"
- lightServer := ctx.GlobalInt(LightServFlag.Name) != 0
- lightPeers := ctx.GlobalInt(LightPeersFlag.Name)
+ lightServer := (ctx.GlobalInt(LightLegacyServFlag.Name) != 0 || ctx.GlobalInt(LightServeFlag.Name) != 0)
+ lightPeers := ctx.GlobalInt(LightLegacyPeersFlag.Name)
+ if ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
+ lightPeers = ctx.GlobalInt(LightMaxPeersFlag.Name)
+ }
if ctx.GlobalIsSet(MaxPeersFlag.Name) {
cfg.MaxPeers = ctx.GlobalInt(MaxPeersFlag.Name)
- if lightServer && !ctx.GlobalIsSet(LightPeersFlag.Name) {
+ if lightServer && !ctx.GlobalIsSet(LightLegacyPeersFlag.Name) && !ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
cfg.MaxPeers += lightPeers
}
} else {
if lightServer {
cfg.MaxPeers += lightPeers
}
- if lightClient && ctx.GlobalIsSet(LightPeersFlag.Name) && cfg.MaxPeers < lightPeers {
+ if lightClient && (ctx.GlobalIsSet(LightLegacyPeersFlag.Name) || ctx.GlobalIsSet(LightMaxPeersFlag.Name)) && cfg.MaxPeers < lightPeers {
cfg.MaxPeers = lightPeers
}
}
@@ -1379,9 +1398,9 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags
CheckExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, GoerliFlag)
- CheckExclusive(ctx, LightServFlag, SyncModeFlag, "light")
- // Can't use both ephemeral unlocked and external signer
- CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag)
+ CheckExclusive(ctx, LightLegacyServFlag, LightServeFlag, SyncModeFlag, "light")
+ CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
+
var ks *keystore.KeyStore
if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0 {
ks = keystores[0].(*keystore.KeyStore)
diff --git a/eth/config.go b/eth/config.go
index 8568f289a..c29655375 100644
--- a/eth/config.go
+++ b/eth/config.go
@@ -102,10 +102,10 @@ type Config struct {
Whitelist map[uint64]common.Hash `toml:"-"`
// Light client options
- LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
- LightBandwidthIn int `toml:",omitempty"` // Incoming bandwidth limit for light servers
- LightBandwidthOut int `toml:",omitempty"` // Outgoing bandwidth limit for light servers
- LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
+ LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
+ LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers
+ LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers
+ LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
// Ultra Light client options
UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers
diff --git a/eth/gen_config.go b/eth/gen_config.go
index f0ffb5a81..a7794ffab 100644
--- a/eth/gen_config.go
+++ b/eth/gen_config.go
@@ -25,8 +25,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
NoPrefetch bool
Whitelist map[uint64]common.Hash `toml:"-"`
LightServ int `toml:",omitempty"`
- LightBandwidthIn int `toml:",omitempty"`
- LightBandwidthOut int `toml:",omitempty"`
+ LightIngress int `toml:",omitempty"`
+ LightEgress int `toml:",omitempty"`
LightPeers int `toml:",omitempty"`
UltraLightServers []string `toml:",omitempty"`
UltraLightFraction int `toml:",omitempty"`
@@ -58,8 +58,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.NoPrefetch = c.NoPrefetch
enc.Whitelist = c.Whitelist
enc.LightServ = c.LightServ
- enc.LightBandwidthIn = c.LightBandwidthIn
- enc.LightBandwidthOut = c.LightBandwidthOut
+ enc.LightIngress = c.LightIngress
+ enc.LightEgress = c.LightEgress
enc.LightPeers = c.LightPeers
enc.UltraLightServers = c.UltraLightServers
enc.UltraLightFraction = c.UltraLightFraction
@@ -95,8 +95,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
NoPrefetch *bool
Whitelist map[uint64]common.Hash `toml:"-"`
LightServ *int `toml:",omitempty"`
- LightBandwidthIn *int `toml:",omitempty"`
- LightBandwidthOut *int `toml:",omitempty"`
+ LightIngress *int `toml:",omitempty"`
+ LightEgress *int `toml:",omitempty"`
LightPeers *int `toml:",omitempty"`
UltraLightServers []string `toml:",omitempty"`
UltraLightFraction *int `toml:",omitempty"`
@@ -145,11 +145,11 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.LightServ != nil {
c.LightServ = *dec.LightServ
}
- if dec.LightBandwidthIn != nil {
- c.LightBandwidthIn = *dec.LightBandwidthIn
+ if dec.LightIngress != nil {
+ c.LightIngress = *dec.LightIngress
}
- if dec.LightBandwidthOut != nil {
- c.LightBandwidthOut = *dec.LightBandwidthOut
+ if dec.LightEgress != nil {
+ c.LightEgress = *dec.LightEgress
}
if dec.LightPeers != nil {
c.LightPeers = *dec.LightPeers
diff --git a/les/costtracker.go b/les/costtracker.go
index 2d9c95af7..61b076d15 100644
--- a/les/costtracker.go
+++ b/les/costtracker.go
@@ -139,11 +139,11 @@ func newCostTracker(db ethdb.Database, config *eth.Config) (*costTracker, uint64
reqInfoCh: make(chan reqInfo, 100),
utilTarget: utilTarget,
}
- if config.LightBandwidthIn > 0 {
- ct.inSizeFactor = utilTarget / float64(config.LightBandwidthIn)
+ if config.LightIngress > 0 {
+ ct.inSizeFactor = utilTarget / float64(config.LightIngress)
}
- if config.LightBandwidthOut > 0 {
- ct.outSizeFactor = utilTarget / float64(config.LightBandwidthOut)
+ if config.LightEgress > 0 {
+ ct.outSizeFactor = utilTarget / float64(config.LightEgress)
}
if makeCostStats {
ct.stats = make(map[uint64][]uint64)