Files
scroll/roller/config/config.go
Lawliet-Chan 2bc951f622 feat: use common lib for verifier & roller (#74)
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
Co-authored-by: colinlyguo <102356659+colinlyguo@users.noreply.github.com>
Co-authored-by: colinlyguo <colinlyguo@gmail.com>
Co-authored-by: HAOYUatHZ <haoyu@protonmail.com>
2022-12-10 18:46:18 +08:00

46 lines
1.1 KiB
Go

package config
import (
"encoding/json"
"os"
"path/filepath"
"github.com/scroll-tech/go-ethereum/log"
)
// Config loads roller configuration items.
type Config struct {
RollerName string `json:"roller_name"`
KeystorePath string `json:"keystore_path"`
KeystorePassword string `json:"keystore_password"`
CoordinatorURL string `json:"coordinator_url"`
Prover *ProverConfig `json:"prover"`
DBPath string `json:"db_path"`
}
// ProverConfig load zk prover config.
type ProverConfig struct {
ParamsPath string `json:"params_path"`
SeedPath string `json:"seed_path"`
}
// NewConfig returns a new instance of Config.
func NewConfig(file string) (*Config, error) {
buf, err := os.ReadFile(filepath.Clean(file))
if err != nil {
return nil, err
}
cfg := &Config{}
if err = json.Unmarshal(buf, cfg); err != nil {
return nil, err
}
if !filepath.IsAbs(cfg.DBPath) {
if cfg.DBPath, err = filepath.Abs(cfg.DBPath); err != nil {
log.Error("Failed to get abs path", "error", err)
return nil, err
}
}
return cfg, nil
}