aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-12-10 21:10:35 +0800
committerGitHub <noreply@github.com>2018-12-10 21:10:35 +0800
commit9fe5d200117bab0b2adbcf1d09629879366bcc54 (patch)
tree7449a43a27c17627540ffde7eb78a8a13ffbe1f7 /cmd/utils/flags.go
parentdd98d1da9464c9ae6e1da69d7a41d4551f20bd8d (diff)
parent31b33349227715e8d1f8753d913892c1e35439d7 (diff)
downloaddexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar.gz
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar.bz2
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar.lz
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar.xz
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.tar.zst
dexon-9fe5d200117bab0b2adbcf1d09629879366bcc54.zip
Merge pull request #18028 from ryanschneider/blockhash-whitelist
cmd, eth: add support for `--whitelist <blocknum>=<hash>`
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 6a285fcb3..c9115d7a3 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -182,6 +182,10 @@ var (
Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
}
+ WhitelistFlag = cli.StringFlag{
+ Name: "whitelist",
+ Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
+ }
// Dashboard settings
DashboardEnabledFlag = cli.BoolFlag{
Name: metrics.DashboardEnabledFlag,
@@ -1072,6 +1076,29 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) {
}
}
+func setWhitelist(ctx *cli.Context, cfg *eth.Config) {
+ 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)
+ }
+ 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
+ }
+}
+
// checkExclusive verifies that only a single instance of the provided flags was
// set by the user. Each flag might optionally be followed by a string type to
// specialize it further.
@@ -1137,6 +1164,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
setGPO(ctx, &cfg.GPO)
setTxPool(ctx, &cfg.TxPool)
setEthash(ctx, cfg)
+ setWhitelist(ctx, cfg)
if ctx.GlobalIsSet(SyncModeFlag.Name) {
cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)