Skip to content

Commit

Permalink
Change order of indexer config
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Jan 22, 2025
1 parent 9bab01c commit d074cc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
const (
flagIndexerEnable = "indexer.enable"
flagIndexerCacheCapacity = "indexer.cache-capacity"
flagIndexerBackend = "indexer.backend"
flagIndexerRetainHeight = "indexer.retain-height"
flagIndexerBackend = "indexer.backend"
)

func NewConfig(appOpts servertypes.AppOptions) (*IndexerConfig, error) {
Expand All @@ -27,14 +27,14 @@ func NewConfig(appOpts servertypes.AppOptions) (*IndexerConfig, error) {

cfg.CacheCapacity = cast.ToInt(appOpts.Get(flagIndexerCacheCapacity))

cfg.RetainHeight = cast.ToUint64(appOpts.Get(flagIndexerRetainHeight))

cfg.BackendConfig = viper.New()
err := cfg.BackendConfig.MergeConfigMap(cast.ToStringMap(appOpts.Get(flagIndexerBackend)))
if err != nil {
return nil, fmt.Errorf("failed to merge backend config: %w", err)
}

cfg.RetainHeight = cast.ToUint64(appOpts.Get(flagIndexerRetainHeight))

return cfg, nil
}

Expand Down Expand Up @@ -62,7 +62,7 @@ func DefaultConfig() IndexerConfig {
return IndexerConfig{
Enable: true,
CacheCapacity: 500, // 500 MiB
BackendConfig: store.DefaultConfig(),
RetainHeight: 0,
BackendConfig: store.DefaultConfig(),
}
}
14 changes: 7 additions & 7 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ type IndexerConfig struct {
Enable bool `mapstructure:"indexer.enable"`
// CacheCapacity defines the size of the cache used by the kvindexer. (unit: MiB)
CacheCapacity int `mapstructure:"indexer.cache-capacity"`
// RetainHeight is the height to retain indexer data.
// If 0, it will retain all data.
RetainHeight uint64 `mapstructure:"indexer.retain-height"`
// Backend defines the type of the backend store and its options.
// It should have a key-value pair named 'type', and the value should exist in store supported by cosmos-db.
// Recommend to use default value unless you know about backend db storage.
// NOTE: "goleveldb" is the only supported type in the current version.
BackendConfig *viper.Viper `mapstructure:"indexer.backend"`
// RetainHeight is the height to retain indexer data.
// If 0, it will retain all data.
RetainHeight uint64 `mapstructure:"indexer.retain-height"`
}

const DefaultConfigTemplate = `
Expand All @@ -33,14 +33,14 @@ enable = {{ .IndexerConfig.Enable }}
# CacheCapacity defines the size of the cache. (unit: MiB)
cache-capacity = {{ .IndexerConfig.CacheCapacity }}
# RetainHeight is the height to retain indexer data.
# If 0, it will retain all data.
retain-height = {{ .IndexerConfig.RetainHeight }}
# Backend defines the type of the backend store and its options.
# It should have a key-value pair named 'type', and the value should exist in store supported by cosmos-db.
# Recommend to use default value unless you know about backend db storage.
# supported type: "goleveldb" only in current
[indexer.backend]
{{ range $key, $value := .IndexerConfig.BackendConfig.AllSettings }}{{ printf "%s = \"%v\"\n" $key $value }}{{end}}
# RetainHeight is the height to retain indexer data.
# If 0, it will retain all data.
retain-height = {{ .IndexerConfig.RetainHeight }}
`

0 comments on commit d074cc5

Please sign in to comment.