From 0cb49cfe0e76873af5d96e78516d02eec041b1a1 Mon Sep 17 00:00:00 2001 From: Matt Curtis Date: Mon, 18 Sep 2023 11:56:02 +0100 Subject: [PATCH] remove superfluous time format check --- go/node/cmd/cli.go | 9 --------- go/node/cmd/main.go | 10 ++-------- go/node/config.go | 8 ++++---- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/go/node/cmd/cli.go b/go/node/cmd/cli.go index f198ebacb8..fd82d60ddd 100644 --- a/go/node/cmd/cli.go +++ b/go/node/cmd/cli.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "strings" - "time" ) var ( @@ -106,15 +105,7 @@ func ParseConfigCLI() *NodeConfigCLI { cfg.logLevel = *logLevel cfg.isInboundP2PDisabled = *isInboundP2PDisabled cfg.batchInterval = *batchInterval - if _, err := time.ParseDuration(cfg.batchInterval); err != nil { - fmt.Printf("invalid batch interval: %s\n", err) - os.Exit(1) - } cfg.rollupInterval = *rollupInterval - if _, err := time.ParseDuration(cfg.rollupInterval); err != nil { - fmt.Printf("invalid rollup interval: %s\n", err) - os.Exit(1) - } cfg.nodeAction = flag.Arg(0) if !validateNodeAction(cfg.nodeAction) { diff --git a/go/node/cmd/main.go b/go/node/cmd/main.go index 5668e51c21..219740df47 100644 --- a/go/node/cmd/main.go +++ b/go/node/cmd/main.go @@ -1,8 +1,6 @@ package main import ( - "time" - "github.com/obscuronet/go-obscuro/go/node" ) @@ -10,10 +8,6 @@ func main() { cliConfig := ParseConfigCLI() // todo (#1618) - allow for multiple operation (start, stop, status) - // we already validated the config in ParseConfigCLI, so we can safely ignore the error here - batchInterval, _ := time.ParseDuration(cliConfig.batchInterval) - rollupInterval, _ := time.ParseDuration(cliConfig.rollupInterval) - nodeCfg := node.NewNodeConfig( node.WithNodeName(cliConfig.nodeName), node.WithNodeType(cliConfig.nodeType), @@ -39,8 +33,8 @@ func main() { node.WithDebugNamespaceEnabled(cliConfig.isDebugNamespaceEnabled), // false node.WithLogLevel(cliConfig.logLevel), node.WithInboundP2PDisabled(cliConfig.isInboundP2PDisabled), - node.WithBatchInterval(batchInterval), - node.WithRollupInterval(rollupInterval), + node.WithBatchInterval(cliConfig.batchInterval), + node.WithRollupInterval(cliConfig.rollupInterval), ) dockerNode := node.NewDockerNode(nodeCfg) diff --git a/go/node/config.go b/go/node/config.go index 78061b4350..ffd9b297b9 100644 --- a/go/node/config.go +++ b/go/node/config.go @@ -48,8 +48,8 @@ type Config struct { logLevel int isInboundP2PDisabled bool l1BlockTime time.Duration - batchInterval time.Duration - rollupInterval time.Duration + batchInterval string + rollupInterval string } func NewNodeConfig(opts ...Option) *Config { @@ -289,13 +289,13 @@ func WithL1BlockTime(d time.Duration) Option { } } -func WithBatchInterval(d time.Duration) Option { +func WithBatchInterval(d string) Option { return func(c *Config) { c.batchInterval = d } } -func WithRollupInterval(d time.Duration) Option { +func WithRollupInterval(d string) Option { return func(c *Config) { c.rollupInterval = d }