aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-07-10 01:30:24 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-07-10 01:34:42 +0800
commit213690cdfd8e49940b68210da05e3836005b96b8 (patch)
tree08225fc3870740c2b12a1802d9d6f55df10fee68 /cmd
parent8c249cb82f713c5c5b5a8160c92da7fe145e799d (diff)
downloadgo-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar.gz
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar.bz2
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar.lz
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar.xz
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.tar.zst
go-tangerine-213690cdfd8e49940b68210da05e3836005b96b8.zip
cmd, eth, les: fix up ultra light config integration
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/config.go2
-rw-r--r--cmd/geth/main.go7
-rw-r--r--cmd/geth/usage.go3
-rw-r--r--cmd/utils/flags.go67
4 files changed, 28 insertions, 51 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go
index ef26f250e..0a63a0277 100644
--- a/cmd/geth/config.go
+++ b/cmd/geth/config.go
@@ -123,7 +123,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
}
// Apply flags.
- utils.SetULC(ctx, &cfg.Eth)
utils.SetNodeConfig(ctx, &cfg.Node)
stack, err := node.New(&cfg.Node)
if err != nil {
@@ -133,7 +132,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
}
-
utils.SetShhConfig(ctx, stack, &cfg.Shh)
utils.SetDashboardConfig(ctx, &cfg.Dashboard)
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index fd8f29421..4d0dc14da 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -90,10 +90,6 @@ var (
utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag,
- utils.ULCModeConfigFlag,
- utils.OnlyAnnounceModeFlag,
- utils.ULCTrustedNodesFlag,
- utils.ULCMinTrustedFractionFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
utils.GCModeFlag,
@@ -102,6 +98,9 @@ var (
utils.LightBandwidthOutFlag,
utils.LightPeersFlag,
utils.LightKDFFlag,
+ utils.UltraLightServersFlag,
+ utils.UltraLightFractionFlag,
+ utils.UltraLightOnlyAnnounceFlag,
utils.WhitelistFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 58a3b87a4..08bd76778 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -86,6 +86,9 @@ var AppHelpFlagGroups = []flagGroup{
utils.LightBandwidthInFlag,
utils.LightBandwidthOutFlag,
utils.LightPeersFlag,
+ utils.UltraLightServersFlag,
+ utils.UltraLightFractionFlag,
+ utils.UltraLightOnlyAnnounceFlag,
utils.LightKDFFlag,
utils.WhitelistFlag,
},
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 9a92e21fe..e381f9bbb 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -19,7 +19,6 @@ package utils
import (
"crypto/ecdsa"
- "encoding/json"
"errors"
"fmt"
"io/ioutil"
@@ -100,7 +99,6 @@ func NewApp(gitCommit, gitDate, usage string) *cli.App {
app := cli.NewApp()
app.Name = filepath.Base(os.Args[0])
app.Author = ""
- //app.Authors = nil
app.Email = ""
app.Version = params.VersionWithCommit(gitCommit, gitDate)
app.Usage = usage
@@ -176,21 +174,19 @@ var (
Name: "exitwhensynced",
Usage: "Exits after block synchronisation completes",
}
- ULCModeConfigFlag = cli.StringFlag{
- Name: "ulc.config",
- Usage: "Config file to use for ultra light client mode",
+ UltraLightServersFlag = cli.StringFlag{
+ Name: "ulc.servers",
+ Usage: "List of trusted ultra-light servers",
+ Value: strings.Join(eth.DefaultConfig.UltraLightServers, ","),
}
- OnlyAnnounceModeFlag = cli.BoolFlag{
- Name: "ulc.onlyannounce",
- Usage: "ULC server sends announcements only",
- }
- ULCMinTrustedFractionFlag = cli.IntFlag{
+ UltraLightFractionFlag = cli.IntFlag{
Name: "ulc.fraction",
- Usage: "Minimum % of trusted ULC servers required to announce a new head",
+ Usage: "Minimum % of trusted ultra-light servers required to announce a new head",
+ Value: eth.DefaultConfig.UltraLightFraction,
}
- ULCTrustedNodesFlag = cli.StringFlag{
- Name: "ulc.trusted",
- Usage: "List of trusted ULC servers",
+ UltraLightOnlyAnnounceFlag = cli.BoolFlag{
+ Name: "ulc.onlyannounce",
+ Usage: "Ultra light server sends announcements only",
}
IterativeOutputFlag = cli.BoolFlag{
Name: "iterative",
@@ -953,37 +949,20 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
}
}
-// SetULC setup ULC config from file if given.
-func SetULC(ctx *cli.Context, cfg *eth.Config) {
- // ULC config isn't loaded from global config and ULC config and ULC trusted nodes are not defined.
- if cfg.ULC == nil && !(ctx.GlobalIsSet(ULCModeConfigFlag.Name) || ctx.GlobalIsSet(ULCTrustedNodesFlag.Name)) {
- return
- }
- cfg.ULC = &eth.ULCConfig{}
-
- path := ctx.GlobalString(ULCModeConfigFlag.Name)
- if path != "" {
- cfgData, err := ioutil.ReadFile(path)
- if err != nil {
- Fatalf("Failed to unmarshal ULC configuration: %v", err)
- }
-
- err = json.Unmarshal(cfgData, &cfg.ULC)
- if err != nil {
- Fatalf("Failed to unmarshal ULC configuration: %s", err.Error())
- }
+// setUltraLight configures the ultra light client settings from the command line flags.
+func setUltraLight(ctx *cli.Context, cfg *eth.Config) {
+ if ctx.GlobalIsSet(UltraLightServersFlag.Name) {
+ cfg.UltraLightServers = strings.Split(ctx.GlobalString(UltraLightServersFlag.Name), ",")
}
-
- if trustedNodes := ctx.GlobalString(ULCTrustedNodesFlag.Name); trustedNodes != "" {
- cfg.ULC.TrustedServers = strings.Split(trustedNodes, ",")
+ if ctx.GlobalIsSet(UltraLightFractionFlag.Name) {
+ cfg.UltraLightFraction = ctx.GlobalInt(UltraLightFractionFlag.Name)
}
-
- if trustedFraction := ctx.GlobalInt(ULCMinTrustedFractionFlag.Name); trustedFraction > 0 {
- cfg.ULC.MinTrustedFraction = trustedFraction
+ if cfg.UltraLightFraction <= 0 && cfg.UltraLightFraction > 100 {
+ log.Error("Ultra light fraction is invalid", "had", cfg.UltraLightFraction, "updated", eth.DefaultConfig.UltraLightFraction)
+ cfg.UltraLightFraction = eth.DefaultConfig.UltraLightFraction
}
- if cfg.ULC.MinTrustedFraction <= 0 && cfg.ULC.MinTrustedFraction > 100 {
- log.Error("MinTrustedFraction is invalid", "MinTrustedFraction", cfg.ULC.MinTrustedFraction, "Changed to default", eth.DefaultULCMinTrustedFraction)
- cfg.ULC.MinTrustedFraction = eth.DefaultULCMinTrustedFraction
+ if ctx.GlobalIsSet(UltraLightOnlyAnnounceFlag.Name) {
+ cfg.UltraLightOnlyAnnounce = ctx.GlobalBool(UltraLightOnlyAnnounceFlag.Name)
}
}
@@ -1400,6 +1379,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
setEthash(ctx, cfg)
setMiner(ctx, &cfg.Miner)
setWhitelist(ctx, cfg)
+ setUltraLight(ctx, cfg)
if ctx.GlobalIsSet(SyncModeFlag.Name) {
cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)
@@ -1412,9 +1392,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if ctx.GlobalIsSet(LightPeersFlag.Name) {
cfg.LightPeers = ctx.GlobalInt(LightPeersFlag.Name)
}
- if ctx.GlobalIsSet(OnlyAnnounceModeFlag.Name) {
- cfg.OnlyAnnounce = ctx.GlobalBool(OnlyAnnounceModeFlag.Name)
- }
if ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = ctx.GlobalUint64(NetworkIdFlag.Name)
}