Browse Source

add config option for tx indexing and disable it by default

pull/412/head
Anton Kaliaev 7 years ago
parent
commit
b08f29cb71
No known key found for this signature in database GPG Key ID: 7B6881D965918214
3 changed files with 12 additions and 2 deletions
  1. +2
    -0
      config/tendermint/config.go
  2. +2
    -0
      config/tendermint_test/config.go
  3. +8
    -2
      state/state.go

+ 2
- 0
config/tendermint/config.go View File

@ -101,6 +101,8 @@ func GetConfig(rootDir string) cfg.Config {
mapConfig.SetDefault("mempool_broadcast", true)
mapConfig.SetDefault("mempool_wal_dir", rootDir+"/data/mempool.wal")
mapConfig.SetDefault("tx_indexer", "none")
return mapConfig
}


+ 2
- 0
config/tendermint_test/config.go View File

@ -107,6 +107,8 @@ func ResetConfig(localPath string) cfg.Config {
mapConfig.SetDefault("mempool_broadcast", true)
mapConfig.SetDefault("mempool_wal_dir", "")
mapConfig.SetDefault("tx_indexer", "none")
logger.SetLogLevel(mapConfig.GetString("log_level"))
return mapConfig


+ 8
- 2
state/state.go View File

@ -44,6 +44,7 @@ type State struct {
TxIndexer tx.Indexer `json:"-"` // Transaction indexer.
}
// Used in tests.
func LoadState(db dbm.DB) *State {
return loadState(db, stateKey)
}
@ -132,8 +133,13 @@ func GetState(config cfg.Config, stateDB dbm.DB) *State {
}
// Transaction indexing
store := dbm.NewDB("tx_indexer", config.GetString("db_backend"), config.GetString("db_dir"))
state.TxIndexer = txindexer.NewKV(store)
switch config.GetString("tx_indexer") {
case "kv":
store := dbm.NewDB("tx_indexer", config.GetString("db_backend"), config.GetString("db_dir"))
state.TxIndexer = txindexer.NewKV(store)
default:
state.TxIndexer = &txindexer.Null{}
}
return state
}


Loading…
Cancel
Save