aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-12-10 20:47:01 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-12-10 20:47:01 +0800
commit31b33349227715e8d1f8753d913892c1e35439d7 (patch)
tree8c4e6bdf0d8bec757e335f10cc16ccea284adadb /cmd/utils/flags.go
parent48b70ecff1152f9eec091ff03b803d997a573b19 (diff)
downloadgo-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar.gz
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar.bz2
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar.lz
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar.xz
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.tar.zst
go-tangerine-31b33349227715e8d1f8753d913892c1e35439d7.zip
cmd/utils, eth: minor polishes on whitelist code
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go41
1 files changed, 18 insertions, 23 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 4727e7cdf..c9115d7a3 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -1077,30 +1077,25 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) {
}
func setWhitelist(ctx *cli.Context, cfg *eth.Config) {
- if ctx.GlobalIsSet(WhitelistFlag.Name) {
- entries := strings.Split(ctx.String(WhitelistFlag.Name), ",")
- whitelist := make(map[uint64]common.Hash)
- for _, entry := range entries {
- split := strings.SplitN(entry, "=", 2)
- if len(split) != 2 {
- Fatalf("invalid whitelist entry: %s", entry)
- }
-
- bn, err := strconv.ParseUint(split[0], 0, 64)
- if err != nil {
- Fatalf("Invalid whitelist block number %s: %v", split[0], err)
- }
-
- hash := common.Hash{}
- err = hash.UnmarshalText([]byte(split[1]))
- if err != nil {
- Fatalf("Invalid whitelist hash %s: %v", split[1], err)
- }
-
- whitelist[bn] = hash
+ whitelist := ctx.GlobalString(WhitelistFlag.Name)
+ if whitelist == "" {
+ return
+ }
+ cfg.Whitelist = make(map[uint64]common.Hash)
+ for _, entry := range strings.Split(whitelist, ",") {
+ parts := strings.Split(entry, "=")
+ if len(parts) != 2 {
+ Fatalf("Invalid whitelist entry: %s", entry)
}
-
- cfg.Whitelist = whitelist
+ number, err := strconv.ParseUint(parts[0], 0, 64)
+ if err != nil {
+ Fatalf("Invalid whitelist block number %s: %v", parts[0], err)
+ }
+ var hash common.Hash
+ if err = hash.UnmarshalText([]byte(parts[1])); err != nil {
+ Fatalf("Invalid whitelist hash %s: %v", parts[1], err)
+ }
+ cfg.Whitelist[number] = hash
}
}