Skip to content

Commit

Permalink
remove superfluous time format check
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed Sep 18, 2023
1 parent 20f5c9a commit 0cb49cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
9 changes: 0 additions & 9 deletions go/node/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"strings"
"time"
)

var (
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 2 additions & 8 deletions go/node/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package main

import (
"time"

"github.com/obscuronet/go-obscuro/go/node"
)

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),
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions go/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 0cb49cf

Please sign in to comment.