move this to plugin utils
This commit is contained in:
parent
fdf1e6c031
commit
06fb10e209
25
cmd/util.go
25
cmd/util.go
@ -10,6 +10,7 @@ import (
|
||||
"github.com/cerc-io/plugeth-statediff/indexer"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||
"github.com/cerc-io/plugeth-statediff/indexer/shared"
|
||||
"github.com/cerc-io/plugeth-statediff/utils"
|
||||
"github.com/cerc-io/plugeth-statediff/utils/log"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
@ -89,28 +90,6 @@ func setupPreRunRanges() []pkg.RangeRequest {
|
||||
return blockRanges
|
||||
}
|
||||
|
||||
// LoadConfig loads chain config from json file
|
||||
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
|
||||
file, err := os.Open(chainConfigPath)
|
||||
if err != nil {
|
||||
log.Error("Failed to read chain config file", "error", err)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
chainConfig := new(params.ChainConfig)
|
||||
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
|
||||
log.Error("invalid chain config file", "error", err)
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debug(fmt.Sprintf("Using chain config from '%s'. Content: %+v", chainConfigPath, chainConfig))
|
||||
|
||||
return chainConfig, nil
|
||||
}
|
||||
|
||||
func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) {
|
||||
// load some necessary params
|
||||
logWithCommand.Debug("Loading statediff service parameters")
|
||||
@ -134,7 +113,7 @@ func instantiateLevelDBReader() (pkg.Reader, *params.ChainConfig, node.Info) {
|
||||
nodeInfo := getEthNodeInfo()
|
||||
|
||||
chainConfigPath := viper.GetString("ethereum.chainConfig")
|
||||
chainConf, err := LoadConfig(chainConfigPath)
|
||||
chainConf, err := utils.LoadConfig(chainConfigPath)
|
||||
if err != nil {
|
||||
logWithCommand.Fatalf("Unable to instantiate chain config: %s", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user