@@ -19,7 +19,6 @@ package utils
19
19
20
20
import (
21
21
"crypto/ecdsa"
22
- "encoding/json"
23
22
"errors"
24
23
"fmt"
25
24
"io/ioutil"
@@ -100,7 +99,6 @@ func NewApp(gitCommit, gitDate, usage string) *cli.App {
100
99
app := cli .NewApp ()
101
100
app .Name = filepath .Base (os .Args [0 ])
102
101
app .Author = ""
103
- //app.Authors = nil
104
102
app .Email = ""
105
103
app .Version = params .VersionWithCommit (gitCommit , gitDate )
106
104
app .Usage = usage
@@ -176,21 +174,19 @@ var (
176
174
Name : "exitwhensynced" ,
177
175
Usage : "Exits after block synchronisation completes" ,
178
176
}
179
- ULCModeConfigFlag = cli.StringFlag {
180
- Name : "ulc.config" ,
181
- Usage : "Config file to use for ultra light client mode" ,
177
+ UltraLightServersFlag = cli.StringFlag {
178
+ Name : "ulc.servers" ,
179
+ Usage : "List of trusted ultra-light servers" ,
180
+ Value : strings .Join (eth .DefaultConfig .UltraLightServers , "," ),
182
181
}
183
- OnlyAnnounceModeFlag = cli.BoolFlag {
184
- Name : "ulc.onlyannounce" ,
185
- Usage : "ULC server sends announcements only" ,
186
- }
187
- ULCMinTrustedFractionFlag = cli.IntFlag {
182
+ UltraLightFractionFlag = cli.IntFlag {
188
183
Name : "ulc.fraction" ,
189
- Usage : "Minimum % of trusted ULC servers required to announce a new head" ,
184
+ Usage : "Minimum % of trusted ultra-light servers required to announce a new head" ,
185
+ Value : eth .DefaultConfig .UltraLightFraction ,
190
186
}
191
- ULCTrustedNodesFlag = cli.StringFlag {
192
- Name : "ulc.trusted " ,
193
- Usage : "List of trusted ULC servers " ,
187
+ UltraLightOnlyAnnounceFlag = cli.BoolFlag {
188
+ Name : "ulc.onlyannounce " ,
189
+ Usage : "Ultra light server sends announcements only " ,
194
190
}
195
191
IterativeOutputFlag = cli.BoolFlag {
196
192
Name : "iterative" ,
@@ -953,37 +949,20 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
953
949
}
954
950
}
955
951
956
- // SetULC setup ULC config from file if given.
957
- func SetULC (ctx * cli.Context , cfg * eth.Config ) {
958
- // ULC config isn't loaded from global config and ULC config and ULC trusted nodes are not defined.
959
- if cfg .ULC == nil && ! (ctx .GlobalIsSet (ULCModeConfigFlag .Name ) || ctx .GlobalIsSet (ULCTrustedNodesFlag .Name )) {
960
- return
961
- }
962
- cfg .ULC = & eth.ULCConfig {}
963
-
964
- path := ctx .GlobalString (ULCModeConfigFlag .Name )
965
- if path != "" {
966
- cfgData , err := ioutil .ReadFile (path )
967
- if err != nil {
968
- Fatalf ("Failed to unmarshal ULC configuration: %v" , err )
969
- }
970
-
971
- err = json .Unmarshal (cfgData , & cfg .ULC )
972
- if err != nil {
973
- Fatalf ("Failed to unmarshal ULC configuration: %s" , err .Error ())
974
- }
952
+ // setUltraLight configures the ultra light client settings from the command line flags.
953
+ func setUltraLight (ctx * cli.Context , cfg * eth.Config ) {
954
+ if ctx .GlobalIsSet (UltraLightServersFlag .Name ) {
955
+ cfg .UltraLightServers = strings .Split (ctx .GlobalString (UltraLightServersFlag .Name ), "," )
975
956
}
976
-
977
- if trustedNodes := ctx .GlobalString (ULCTrustedNodesFlag .Name ); trustedNodes != "" {
978
- cfg .ULC .TrustedServers = strings .Split (trustedNodes , "," )
957
+ if ctx .GlobalIsSet (UltraLightFractionFlag .Name ) {
958
+ cfg .UltraLightFraction = ctx .GlobalInt (UltraLightFractionFlag .Name )
979
959
}
980
-
981
- if trustedFraction := ctx . GlobalInt ( ULCMinTrustedFractionFlag . Name ); trustedFraction > 0 {
982
- cfg .ULC . MinTrustedFraction = trustedFraction
960
+ if cfg . UltraLightFraction <= 0 && cfg . UltraLightFraction > 100 {
961
+ log . Error ( "Ultra light fraction is invalid" , "had" , cfg . UltraLightFraction , "updated" , eth . DefaultConfig . UltraLightFraction )
962
+ cfg .UltraLightFraction = eth . DefaultConfig . UltraLightFraction
983
963
}
984
- if cfg .ULC .MinTrustedFraction <= 0 && cfg .ULC .MinTrustedFraction > 100 {
985
- log .Error ("MinTrustedFraction is invalid" , "MinTrustedFraction" , cfg .ULC .MinTrustedFraction , "Changed to default" , eth .DefaultULCMinTrustedFraction )
986
- cfg .ULC .MinTrustedFraction = eth .DefaultULCMinTrustedFraction
964
+ if ctx .GlobalIsSet (UltraLightOnlyAnnounceFlag .Name ) {
965
+ cfg .UltraLightOnlyAnnounce = ctx .GlobalBool (UltraLightOnlyAnnounceFlag .Name )
987
966
}
988
967
}
989
968
@@ -1400,6 +1379,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
1400
1379
setEthash (ctx , cfg )
1401
1380
setMiner (ctx , & cfg .Miner )
1402
1381
setWhitelist (ctx , cfg )
1382
+ setUltraLight (ctx , cfg )
1403
1383
1404
1384
if ctx .GlobalIsSet (SyncModeFlag .Name ) {
1405
1385
cfg .SyncMode = * GlobalTextMarshaler (ctx , SyncModeFlag .Name ).(* downloader.SyncMode )
@@ -1412,9 +1392,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
1412
1392
if ctx .GlobalIsSet (LightPeersFlag .Name ) {
1413
1393
cfg .LightPeers = ctx .GlobalInt (LightPeersFlag .Name )
1414
1394
}
1415
- if ctx .GlobalIsSet (OnlyAnnounceModeFlag .Name ) {
1416
- cfg .OnlyAnnounce = ctx .GlobalBool (OnlyAnnounceModeFlag .Name )
1417
- }
1418
1395
if ctx .GlobalIsSet (NetworkIdFlag .Name ) {
1419
1396
cfg .NetworkId = ctx .GlobalUint64 (NetworkIdFlag .Name )
1420
1397
}
0 commit comments