fix CLI bug

This commit is contained in:
i-norden 2021-10-20 16:25:52 -05:00
parent 4cbaa630c7
commit 0dcec4ec8e
2 changed files with 10 additions and 9 deletions

View File

@ -31,10 +31,10 @@ const (
DB_CACHE_SIZE_MB = "DB_CACHE_SIZE_MB"
TRIE_CACHE_SIZE_MB = "TRIE_CACHE_SIZE_MB"
WRITE_SERVER = "WRITE_SERVER"
STATEDIFF_WORKERS = "STATEDIFF_WORKERS"
LVLDB_PATH = "LVLDB_PATH"
LVLDB_ANCIENT = "LVLDB_ANCIENT"
STATEDIFF_WORKERS = "STATEDIFF_WORKERS"
WRITE_SERVER = "WRITE_SERVER"
)
// Bind env vars for eth node and DB configuration
@ -57,7 +57,8 @@ func init() {
viper.BindEnv("cache.database", DB_CACHE_SIZE_MB)
viper.BindEnv("cache.trie", TRIE_CACHE_SIZE_MB)
viper.BindEnv("write.serve", WRITE_SERVER)
viper.BindEnv("leveldb.path", LVLDB_PATH)
viper.BindEnv("leveldb.ancient", LVLDB_ANCIENT)
viper.BindEnv("statediff.workers", STATEDIFF_WORKERS)
}

View File

@ -50,14 +50,15 @@ type blockRange [2]uint64
func init() {
rootCmd.AddCommand(writeCmd)
writeCmd.Flags().String("serve", "", "starts a server which handles write request through endpoints")
viper.BindPFlag("write.serve", writeCmd.PersistentFlags().Lookup("serve"))
writeCmd.PersistentFlags().String("write-api", "", "starts a server which handles write request through endpoints")
viper.BindPFlag("write.serve", writeCmd.PersistentFlags().Lookup("write-api"))
}
func write() {
logWithCommand.Info("Starting statediff writer")
// load params
viper.BindEnv("write.serve", WRITE_SERVER)
addr := viper.GetString("write.serve")
path := viper.GetString("leveldb.path")
ancientPath := viper.GetString("leveldb.ancient")
if path == "" || ancientPath == "" {
@ -119,7 +120,6 @@ func write() {
viper.UnmarshalKey("write.params", &diffParams)
blockRangesCh := make(chan blockRange, 100)
addr := viper.GetString("write.serve")
go func() {
for _, r := range blockRanges {
blockRangesCh <- r