Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update config default #39

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,3 @@ Indexer listens StreamingManager's stream and indices streamed data

Registered submodules get abci Events(i.e. FinalizeBlock and Commit) and are allowed to CRUD indexer key-value storage.

### Configuration

Default configuration will be set when the indexer is initialized.
But, to run your indexer properly, you have to set 2 configuration properties.

* set indexer.enable to true in app.toml
* set indexer.l1-chain-id to the L1's chain id app.toml

Here's example:
```toml
[indexer]
enable = true
l1-chain-id = "mahalo-2"

#...other properties..
```

Other properties are okay with default!
9 changes: 1 addition & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const (
flagIndexerEnable = "indexer.enable"
flagIndexerBackend = "indexer.backend"
flagIndexerCacheSize = "indexer.cache-size"
flagL1ChainId = "indexer.l1-chain-id"
)

func NewConfig(appOpts servertypes.AppOptions) (*IndexerConfig, error) {
Expand All @@ -25,7 +24,6 @@ func NewConfig(appOpts servertypes.AppOptions) (*IndexerConfig, error) {
return cfg, nil
}
cfg.CacheSize = cast.ToUint(appOpts.Get(flagIndexerCacheSize))
cfg.L1ChainId = cast.ToString(appOpts.Get(flagL1ChainId))

cfg.BackendConfig = viper.New()
err := cfg.BackendConfig.MergeConfigMap(cast.ToStringMap(appOpts.Get(flagIndexerBackend)))
Expand All @@ -47,10 +45,6 @@ func (c IndexerConfig) Validate() error {
return fmt.Errorf("cache size must be greater than 0")
}

if c.L1ChainId == "" {
return fmt.Errorf("l1 chain id must be set")
}

if c.BackendConfig == nil {
return fmt.Errorf("backend config must be set")
}
Expand All @@ -64,9 +58,8 @@ func (c IndexerConfig) IsEnabled() bool {

func DefaultConfig() IndexerConfig {
return IndexerConfig{
Enable: false,
Enable: true,
CacheSize: 1_000_000,
L1ChainId: "",
BackendConfig: store.DefaultConfig(),
}
}
4 changes: 0 additions & 4 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
type IndexerConfig struct {
Enable bool `mapstructure:"indexer.enable"`
CacheSize uint `mapstructure:"indexer.cache-size"`
L1ChainId string `mapstructure:"indexer.l1-chain-id"`
BackendConfig *viper.Viper `mapstructure:"indexer.backend"`
}

Expand All @@ -24,9 +23,6 @@ enable = {{ .IndexerConfig.Enable }}
# CacheSize defines the size of the cache.
cache-size = {{ .IndexerConfig.CacheSize }}

# l1-chain-id defines the chain id of the l1 chain.
l1-chain-id = "{{ .IndexerConfig.L1ChainId }}"

# 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.
# supported type: "goleveldb" only in current
Expand Down
Loading