From 84e22adfbab06080b94f6e10d0af14aa4f5ec215 Mon Sep 17 00:00:00 2001 From: Edwin Date: Thu, 22 Jun 2017 15:02:44 +0800 Subject: [PATCH] cmd/*: add Istanbul command line flags --- cmd/geth/main.go | 2 ++ cmd/geth/usage.go | 7 +++++++ cmd/utils/flags.go | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index f5a3fa941a..9eb428c9d7 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -122,6 +122,8 @@ var ( utils.GpoPercentileFlag, utils.ExtraDataFlag, configFileFlag, + utils.IstanbulRequestTimeoutFlag, + utils.IstanbulBlockPeriodFlag, } rpcFlags = []cli.Flag{ diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index a1558c2330..532faba3c8 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -225,6 +225,13 @@ var AppHelpFlagGroups = []flagGroup{ { Name: "MISC", }, + { + Name: "ISTANBUL", + Flags: []cli.Flag{ + utils.IstanbulRequestTimeoutFlag, + utils.IstanbulBlockPeriodFlag, + }, + }, } // byCategory sorts an array of flagGroup by Name in the order diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ff78a0fcc7..df173f9b46 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -532,6 +532,18 @@ var ( Usage: "Minimum POW accepted", Value: whisper.DefaultMinimumPoW, } + + // Istanbul settings + IstanbulRequestTimeoutFlag = cli.Uint64Flag{ + Name: "istanbul.requesttimeout", + Usage: "Timeout for each Istanbul round in milliseconds", + Value: eth.DefaultConfig.Istanbul.RequestTimeout, + } + IstanbulBlockPeriodFlag = cli.Uint64Flag{ + Name: "istanbul.blockperiod", + Usage: "Default minimum difference between two consecutive block's timestamps in seconds", + Value: eth.DefaultConfig.Istanbul.BlockPeriod, + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -961,6 +973,15 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) { } } +func setIstanbul(ctx *cli.Context, cfg *eth.Config) { + if ctx.GlobalIsSet(IstanbulRequestTimeoutFlag.Name) { + cfg.Istanbul.RequestTimeout = ctx.GlobalUint64(IstanbulRequestTimeoutFlag.Name) + } + if ctx.GlobalIsSet(IstanbulBlockPeriodFlag.Name) { + cfg.Istanbul.BlockPeriod = ctx.GlobalUint64(IstanbulBlockPeriodFlag.Name) + } +} + // checkExclusive verifies that only a single isntance of the provided flags was // set by the user. Each flag might optionally be followed by a string type to // specialize it further. @@ -1022,6 +1043,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { setGPO(ctx, &cfg.GPO) setTxPool(ctx, &cfg.TxPool) setEthash(ctx, cfg) + setIstanbul(ctx, cfg) switch { case ctx.GlobalIsSet(SyncModeFlag.Name):