Browse Source

add tx_index config

pull/835/head
Anton Kaliaev 7 years ago
parent
commit
cd4be1f308
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 25 additions and 5 deletions
  1. +24
    -4
      config/config.go
  2. +1
    -1
      node/node.go

+ 24
- 4
config/config.go View File

@ -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


+ 1
- 1
node/node.go View File

@ -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 {


Loading…
Cancel
Save