Commit a005a070 authored by Michael de Hoog's avatar Michael de Hoog

Fix import cycle

parent 4ffc8e40
package batcher package batcher
import ( import (
"fmt"
"strings" "strings"
"time" "time"
...@@ -145,7 +144,7 @@ func NewConfig(ctx *cli.Context) CLIConfig { ...@@ -145,7 +144,7 @@ func NewConfig(ctx *cli.Context) CLIConfig {
TargetL1TxSize: ctx.GlobalUint64(flags.TargetL1TxSizeBytesFlag.Name), TargetL1TxSize: ctx.GlobalUint64(flags.TargetL1TxSizeBytesFlag.Name),
TargetNumFrames: ctx.GlobalInt(flags.TargetNumFramesFlag.Name), TargetNumFrames: ctx.GlobalInt(flags.TargetNumFramesFlag.Name),
ApproxComprRatio: ctx.GlobalFloat64(flags.ApproxComprRatioFlag.Name), ApproxComprRatio: ctx.GlobalFloat64(flags.ApproxComprRatioFlag.Name),
CompressorKind: CompressorKind(strings.ToLower(ctx.GlobalString(flags.CompressorFlag.Name))), CompressorKind: flags.CompressorKind(strings.ToLower(ctx.GlobalString(flags.CompressorFlag.Name))),
Stopped: ctx.GlobalBool(flags.StoppedFlag.Name), Stopped: ctx.GlobalBool(flags.StoppedFlag.Name),
TxMgrConfig: txmgr.ReadCLIConfig(ctx), TxMgrConfig: txmgr.ReadCLIConfig(ctx),
RPCConfig: rpc.ReadCLIConfig(ctx), RPCConfig: rpc.ReadCLIConfig(ctx),
...@@ -157,7 +156,7 @@ func NewConfig(ctx *cli.Context) CLIConfig { ...@@ -157,7 +156,7 @@ func NewConfig(ctx *cli.Context) CLIConfig {
func (c CLIConfig) NewCompressor() (derive.Compressor, error) { func (c CLIConfig) NewCompressor() (derive.Compressor, error) {
switch c.CompressorKind { switch c.CompressorKind {
case CompressorShadow: case flags.CompressorShadow:
return NewShadowCompressor( return NewShadowCompressor(
c.MaxL1TxSize - 1, // subtract 1 byte for version c.MaxL1TxSize - 1, // subtract 1 byte for version
) )
...@@ -169,37 +168,3 @@ func (c CLIConfig) NewCompressor() (derive.Compressor, error) { ...@@ -169,37 +168,3 @@ func (c CLIConfig) NewCompressor() (derive.Compressor, error) {
) )
} }
} }
// CompressorKind identifies a compressor implementation.
type CompressorKind string
const (
CompressorTarget CompressorKind = "target"
CompressorShadow CompressorKind = "shadow"
)
var CompressorKinds = []CompressorKind{
CompressorTarget,
CompressorShadow,
}
func (kind CompressorKind) String() string {
return string(kind)
}
func (kind *CompressorKind) Set(value string) error {
if !ValidCompressorKind(CompressorKind(value)) {
return fmt.Errorf("unknown compressor kind: %q", value)
}
*kind = CompressorKind(value)
return nil
}
func ValidCompressorKind(value CompressorKind) bool {
for _, k := range CompressorKinds {
if k == value {
return true
}
}
return false
}
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/rpc" "github.com/ethereum-optimism/optimism/op-batcher/rpc"
"github.com/ethereum-optimism/optimism/op-node/flags" "github.com/ethereum-optimism/optimism/op-node/flags"
opservice "github.com/ethereum-optimism/optimism/op-service" opservice "github.com/ethereum-optimism/optimism/op-service"
...@@ -90,10 +89,10 @@ var ( ...@@ -90,10 +89,10 @@ var (
CompressorFlag = cli.GenericFlag{ CompressorFlag = cli.GenericFlag{
Name: "compressor", Name: "compressor",
Usage: "The type of compressor. Valid options: " + Usage: "The type of compressor. Valid options: " +
flags.EnumString[batcher.CompressorKind](batcher.CompressorKinds), flags.EnumString[CompressorKind](CompressorKinds),
EnvVar: opservice.PrefixEnvVar(envVarPrefix, "COMPRESSOR"), EnvVar: opservice.PrefixEnvVar(envVarPrefix, "COMPRESSOR"),
Value: func() *batcher.CompressorKind { Value: func() *CompressorKind {
out := batcher.CompressorTarget out := CompressorTarget
return &out return &out
}(), }(),
} }
...@@ -148,3 +147,37 @@ func CheckRequired(ctx *cli.Context) error { ...@@ -148,3 +147,37 @@ func CheckRequired(ctx *cli.Context) error {
} }
return nil return nil
} }
// CompressorKind identifies a compressor implementation.
type CompressorKind string
const (
CompressorTarget CompressorKind = "target"
CompressorShadow CompressorKind = "shadow"
)
var CompressorKinds = []CompressorKind{
CompressorTarget,
CompressorShadow,
}
func (kind CompressorKind) String() string {
return string(kind)
}
func (kind *CompressorKind) Set(value string) error {
if !ValidCompressorKind(CompressorKind(value)) {
return fmt.Errorf("unknown compressor kind: %q", value)
}
*kind = CompressorKind(value)
return nil
}
func ValidCompressorKind(value CompressorKind) bool {
for _, k := range CompressorKinds {
if k == value {
return true
}
}
return false
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment