Commit e88956a9 authored by protolambda's avatar protolambda

op-node: deduplicate rollup config override paths

parent 15646e41
...@@ -198,20 +198,12 @@ Startup will proceed to use the network-parameter and ignore the rollup config. ...@@ -198,20 +198,12 @@ Startup will proceed to use the network-parameter and ignore the rollup config.
Conflicting configuration is deprecated, and will stop the op-node from starting in the future. Conflicting configuration is deprecated, and will stop the op-node from starting in the future.
`, "network", network, "rollup_config", rollupConfigPath) `, "network", network, "rollup_config", rollupConfigPath)
} }
config, err := chaincfg.GetRollupConfig(network) rollupConfig, err := chaincfg.GetRollupConfig(network)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if ctx.IsSet(flags.CanyonOverrideFlag.Name) { applyOverrides(ctx, rollupConfig)
canyon := ctx.Uint64(flags.CanyonOverrideFlag.Name) return rollupConfig, nil
config.CanyonTime = &canyon
}
if ctx.IsSet(flags.DeltaOverrideFlag.Name) {
delta := ctx.Uint64(flags.DeltaOverrideFlag.Name)
config.DeltaTime = &delta
}
return config, nil
} }
file, err := os.Open(rollupConfigPath) file, err := os.Open(rollupConfigPath)
...@@ -224,6 +216,11 @@ Conflicting configuration is deprecated, and will stop the op-node from starting ...@@ -224,6 +216,11 @@ Conflicting configuration is deprecated, and will stop the op-node from starting
if err := json.NewDecoder(file).Decode(&rollupConfig); err != nil { if err := json.NewDecoder(file).Decode(&rollupConfig); err != nil {
return nil, fmt.Errorf("failed to decode rollup config: %w", err) return nil, fmt.Errorf("failed to decode rollup config: %w", err)
} }
applyOverrides(ctx, &rollupConfig)
return &rollupConfig, nil
}
func applyOverrides(ctx *cli.Context, rollupConfig *rollup.Config) {
if ctx.IsSet(flags.CanyonOverrideFlag.Name) { if ctx.IsSet(flags.CanyonOverrideFlag.Name) {
canyon := ctx.Uint64(flags.CanyonOverrideFlag.Name) canyon := ctx.Uint64(flags.CanyonOverrideFlag.Name)
rollupConfig.CanyonTime = &canyon rollupConfig.CanyonTime = &canyon
...@@ -232,7 +229,6 @@ Conflicting configuration is deprecated, and will stop the op-node from starting ...@@ -232,7 +229,6 @@ Conflicting configuration is deprecated, and will stop the op-node from starting
delta := ctx.Uint64(flags.DeltaOverrideFlag.Name) delta := ctx.Uint64(flags.DeltaOverrideFlag.Name)
rollupConfig.DeltaTime = &delta rollupConfig.DeltaTime = &delta
} }
return &rollupConfig, nil
} }
func NewSnapshotLogger(ctx *cli.Context) (log.Logger, error) { func NewSnapshotLogger(ctx *cli.Context) (log.Logger, error) {
......
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