Compare commits
5 Commits
be7b6f5a33
...
7b47871269
Author | SHA1 | Date | |
---|---|---|---|
7b47871269 | |||
2708518798 | |||
1003fe4eea | |||
e49839f859 | |||
b9cba4c605 |
16
cmd/root.go
16
cmd/root.go
@ -156,10 +156,10 @@ func init() {
|
||||
rootCmd.PersistentFlags().Bool("prom-db-stats", false, "enables prometheus db stats")
|
||||
rootCmd.PersistentFlags().Bool("prom-metrics", false, "enable prometheus metrics")
|
||||
|
||||
rootCmd.PersistentFlags().Bool("prerun-include-block", true, "include block data in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("prerun-include-receipts", true, "include receipts in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("prerun-include-td", true, "include td in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("prerun-include-code", true, "include code and codehash mappings in statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("run-include-block", true, "include block data in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("run-include-receipts", true, "include receipts in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("run-include-td", true, "include td in the statediff payload")
|
||||
rootCmd.PersistentFlags().Bool("run-include-code", true, "include code and codehash mappings in statediff payload")
|
||||
|
||||
viper.BindPFlag("server.httpPath", rootCmd.PersistentFlags().Lookup("http-path"))
|
||||
viper.BindPFlag("server.ipcPath", rootCmd.PersistentFlags().Lookup("ipc-path"))
|
||||
@ -208,10 +208,10 @@ func init() {
|
||||
viper.BindPFlag("prom.dbStats", rootCmd.PersistentFlags().Lookup("prom-db-stats"))
|
||||
viper.BindPFlag("prom.metrics", rootCmd.PersistentFlags().Lookup("prom-metrics"))
|
||||
|
||||
viper.BindPFlag("prerun.params.includeBlock", rootCmd.PersistentFlags().Lookup("prerun-include-block"))
|
||||
viper.BindPFlag("prerun.params.includeReceipts", rootCmd.PersistentFlags().Lookup("prerun-include-receipts"))
|
||||
viper.BindPFlag("prerun.params.includeTD", rootCmd.PersistentFlags().Lookup("prerun-include-td"))
|
||||
viper.BindPFlag("prerun.params.includeCode", rootCmd.PersistentFlags().Lookup("prerun-include-code"))
|
||||
viper.BindPFlag("run.params.includeBlock", rootCmd.PersistentFlags().Lookup("run-include-block"))
|
||||
viper.BindPFlag("run.params.includeReceipts", rootCmd.PersistentFlags().Lookup("run-include-receipts"))
|
||||
viper.BindPFlag("run.params.includeTD", rootCmd.PersistentFlags().Lookup("run-include-td"))
|
||||
viper.BindPFlag("run.params.includeCode", rootCmd.PersistentFlags().Lookup("run-include-code"))
|
||||
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
@ -43,14 +43,14 @@ var runCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(runCmd)
|
||||
}
|
||||
|
||||
func runRanges() {
|
||||
service := createStateDiffService()
|
||||
|
||||
// start service and servers
|
||||
var wg sync.WaitGroup
|
||||
if err := service.Loop(&wg); err != nil {
|
||||
logWithCommand.Fatalf("unable to start statediff service: %v", err)
|
||||
}
|
||||
ranges := getConfiguredRanges()
|
||||
service.Run(ranges)
|
||||
|
||||
|
24
cmd/util.go
24
cmd/util.go
@ -6,10 +6,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
gethsd "github.com/cerc-io/plugeth-statediff"
|
||||
ind "github.com/cerc-io/plugeth-statediff/indexer"
|
||||
"github.com/cerc-io/plugeth-statediff/utils/log"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"github.com/spf13/viper"
|
||||
@ -88,3 +86,25 @@ func createStateDiffService() *sd.Service {
|
||||
}
|
||||
return sd.NewStateDiffService(lvlDBReader, indexer, sdConf)
|
||||
}
|
||||
|
||||
// LoadConfig loads chain config from json file
|
||||
func LoadConfig(chainConfigPath string) (*params.ChainConfig, error) {
|
||||
file, err := os.Open(chainConfigPath)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Failed to read chain config file: %v", err))
|
||||
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
chainConfig := new(params.ChainConfig)
|
||||
if err := json.NewDecoder(file).Decode(chainConfig); err != nil {
|
||||
log.Error(fmt.Sprintf("invalid chain config file: %v", err))
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info(fmt.Sprintf("Using chain config from %s file. Content %+v", chainConfigPath, chainConfig))
|
||||
|
||||
return chainConfig, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user