add config option for tx indexing and disable it by default

This commit is contained in:
Anton Kaliaev
2017-02-22 12:15:53 +04:00
parent d62e85757f
commit b08f29cb71
3 changed files with 12 additions and 2 deletions

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
}