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

Fix import cycle

parent 4ffc8e40
package batcher
import (
"fmt"
"strings"
"time"
......@@ -145,7 +144,7 @@ func NewConfig(ctx *cli.Context) CLIConfig {
TargetL1TxSize: ctx.GlobalUint64(flags.TargetL1TxSizeBytesFlag.Name),
TargetNumFrames: ctx.GlobalInt(flags.TargetNumFramesFlag.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),
TxMgrConfig: txmgr.ReadCLIConfig(ctx),
RPCConfig: rpc.ReadCLIConfig(ctx),
......@@ -157,7 +156,7 @@ func NewConfig(ctx *cli.Context) CLIConfig {
func (c CLIConfig) NewCompressor() (derive.Compressor, error) {
switch c.CompressorKind {
case CompressorShadow:
case flags.CompressorShadow:
return NewShadowCompressor(
c.MaxL1TxSize - 1, // subtract 1 byte for version
)
......@@ -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 (
"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-node/flags"
opservice "github.com/ethereum-optimism/optimism/op-service"
......@@ -90,10 +89,10 @@ var (
CompressorFlag = cli.GenericFlag{
Name: "compressor",
Usage: "The type of compressor. Valid options: " +
flags.EnumString[batcher.CompressorKind](batcher.CompressorKinds),
flags.EnumString[CompressorKind](CompressorKinds),
EnvVar: opservice.PrefixEnvVar(envVarPrefix, "COMPRESSOR"),
Value: func() *batcher.CompressorKind {
out := batcher.CompressorTarget
Value: func() *CompressorKind {
out := CompressorTarget
return &out
}(),
}
......@@ -148,3 +147,37 @@ func CheckRequired(ctx *cli.Context) error {
}
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