diff --git a/config/config.go b/config/config.go index 25d6c44a5..97d55ff82 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,7 @@ type Config struct { P2P *P2PConfig `mapstructure:"p2p"` Mempool *MempoolConfig `mapstructure:"mempool"` Consensus *ConsensusConfig `mapstructure:"consensus"` + TxIndex *TxIndexConfig `mapstructure:"tx_index"` } // DefaultConfig returns a default configuration for a Tendermint node @@ -26,6 +27,7 @@ func DefaultConfig() *Config { P2P: DefaultP2PConfig(), Mempool: DefaultMempoolConfig(), Consensus: DefaultConsensusConfig(), + TxIndex: DefaultTxIndexConfig(), } } @@ -37,6 +39,7 @@ func TestConfig() *Config { P2P: TestP2PConfig(), Mempool: DefaultMempoolConfig(), Consensus: TestConsensusConfig(), + TxIndex: DefaultTxIndexConfig(), } } @@ -93,9 +96,6 @@ type BaseConfig struct { // so the app can decide if we should keep the connection or not FilterPeers bool `mapstructure:"filter_peers"` // false - // What indexer to use for transactions - TxIndex string `mapstructure:"tx_index"` - // Database backend: leveldb | memdb DBBackend string `mapstructure:"db_backend"` @@ -115,7 +115,6 @@ func DefaultBaseConfig() BaseConfig { ProfListenAddress: "", FastSync: true, FilterPeers: false, - TxIndex: "kv", DBBackend: "leveldb", DBPath: "data", } @@ -412,6 +411,27 @@ func (c *ConsensusConfig) SetWalFile(walFile string) { c.walFile = walFile } +//----------------------------------------------------------------------------- +// TxIndexConfig + +// TxIndexConfig defines the confuguration for the transaction +// indexer, including tags to index. +type TxIndexConfig struct { + // What indexer to use for transactions + Indexer string `mapstructure:"indexer"` + + // Comma-separated list of tags to index (by default only by tx hash) + IndexTags string `mapstructure:"index_tags"` +} + +// DefaultTxIndexConfig returns a default configuration for the transaction indexer. +func DefaultTxIndexConfig() *TxIndexConfig { + return &TxIndexConfig{ + Indexer: "kv", + IndexTags: "tx.hash", // types.TxHashKey + } +} + //----------------------------------------------------------------------------- // Utils diff --git a/node/node.go b/node/node.go index 5b8ab994a..c0e4197b9 100644 --- a/node/node.go +++ b/node/node.go @@ -175,7 +175,7 @@ func NewNode(config *cfg.Config, // Transaction indexing var txIndexer txindex.TxIndexer - switch config.TxIndex { + switch config.TxIndex.Indexer { case "kv": store, err := dbProvider(&DBContext{"tx_index", config}) if err != nil {