Browse Source

Merge pull request #2333 from tendermint/anton/docs

Update indexing docs & write a test cast
pull/2339/head
Ethan Buchman 6 years ago
committed by GitHub
parent
commit
39ab199181
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 20 deletions
  1. +11
    -6
      config/config.go
  2. +9
    -4
      config/toml.go
  3. +9
    -5
      docs/app-dev/indexing-transactions.md
  4. +9
    -4
      docs/tendermint-core/configuration.md
  5. +5
    -0
      rpc/client/rpc_test.go
  6. +1
    -1
      rpc/test/helpers.go

+ 11
- 6
config/config.go View File

@ -575,8 +575,8 @@ func (cfg *ConsensusConfig) SetWalFile(walFile string) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// TxIndexConfig // TxIndexConfig
// TxIndexConfig defines the configuration for the transaction
// indexer, including tags to index.
// TxIndexConfig defines the configuration for the transaction indexer,
// including tags to index.
type TxIndexConfig struct { type TxIndexConfig struct {
// What indexer to use for transactions // What indexer to use for transactions
// //
@ -585,16 +585,21 @@ type TxIndexConfig struct {
// 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). // 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
Indexer string `mapstructure:"indexer"` Indexer string `mapstructure:"indexer"`
// Comma-separated list of tags to index (by default the only tag is tx hash)
// Comma-separated list of tags to index (by default the only tag is "tx.hash")
// //
// You can also index transactions by height by adding "tx.height" tag here.
//
// It's recommended to index only a subset of tags due to possible memory // It's recommended to index only a subset of tags due to possible memory
// bloat. This is, of course, depends on the indexer's DB and the volume of // bloat. This is, of course, depends on the indexer's DB and the volume of
// transactions. // transactions.
IndexTags string `mapstructure:"index_tags"` IndexTags string `mapstructure:"index_tags"`
// When set to true, tells indexer to index all tags. Note this may be not
// desirable (see the comment above). IndexTags has a precedence over
// IndexAllTags (i.e. when given both, IndexTags will be indexed).
// When set to true, tells indexer to index all tags (predefined tags:
// "tx.hash", "tx.height" and all tags from DeliverTx responses).
//
// Note this may be not desirable (see the comment above). IndexTags has a
// precedence over IndexAllTags (i.e. when given both, IndexTags will be
// indexed).
IndexAllTags bool `mapstructure:"index_all_tags"` IndexAllTags bool `mapstructure:"index_all_tags"`
} }


+ 9
- 4
config/toml.go View File

@ -247,16 +247,21 @@ peer_query_maj23_sleep_duration = {{ .Consensus.PeerQueryMaj23SleepDuration }}
# 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). # 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
indexer = "{{ .TxIndex.Indexer }}" indexer = "{{ .TxIndex.Indexer }}"
# Comma-separated list of tags to index (by default the only tag is tx hash)
# Comma-separated list of tags to index (by default the only tag is "tx.hash")
#
# You can also index transactions by height by adding "tx.height" tag here.
# #
# It's recommended to index only a subset of tags due to possible memory # It's recommended to index only a subset of tags due to possible memory
# bloat. This is, of course, depends on the indexer's DB and the volume of # bloat. This is, of course, depends on the indexer's DB and the volume of
# transactions. # transactions.
index_tags = "{{ .TxIndex.IndexTags }}" index_tags = "{{ .TxIndex.IndexTags }}"
# When set to true, tells indexer to index all tags. Note this may be not
# desirable (see the comment above). IndexTags has a precedence over
# IndexAllTags (i.e. when given both, IndexTags will be indexed).
# When set to true, tells indexer to index all tags (predefined tags:
# "tx.hash", "tx.height" and all tags from DeliverTx responses).
#
# Note this may be not desirable (see the comment above). IndexTags has a
# precedence over IndexAllTags (i.e. when given both, IndexTags will be
# indexed).
index_all_tags = {{ .TxIndex.IndexAllTags }} index_all_tags = {{ .TxIndex.IndexAllTags }}
##### instrumentation configuration options ##### ##### instrumentation configuration options #####


+ 9
- 5
docs/app-dev/indexing-transactions.md View File

@ -16,16 +16,21 @@ Let's take a look at the `[tx_index]` config section:
# 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). # 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
indexer = "kv" indexer = "kv"
# Comma-separated list of tags to index (by default the only tag is tx hash)
# Comma-separated list of tags to index (by default the only tag is "tx.hash")
#
# You can also index transactions by height by adding "tx.height" tag here.
# #
# It's recommended to index only a subset of tags due to possible memory # It's recommended to index only a subset of tags due to possible memory
# bloat. This is, of course, depends on the indexer's DB and the volume of # bloat. This is, of course, depends on the indexer's DB and the volume of
# transactions. # transactions.
index_tags = "" index_tags = ""
# When set to true, tells indexer to index all tags. Note this may be not
# desirable (see the comment above). IndexTags has a precedence over
# IndexAllTags (i.e. when given both, IndexTags will be indexed).
# When set to true, tells indexer to index all tags (predefined tags:
# "tx.hash", "tx.height" and all tags from DeliverTx responses).
#
# Note this may be not desirable (see the comment above). IndexTags has a
# precedence over IndexAllTags (i.e. when given both, IndexTags will be
# indexed).
index_all_tags = false index_all_tags = false
``` ```
@ -59,7 +64,6 @@ all tags, set `index_all_tags=true`
Note, there are a few predefined tags: Note, there are a few predefined tags:
- `tm.event` (event type)
- `tx.hash` (transaction's hash) - `tx.hash` (transaction's hash)
- `tx.height` (height of the block transaction was committed in) - `tx.height` (height of the block transaction was committed in)


+ 9
- 4
docs/tendermint-core/configuration.md View File

@ -194,16 +194,21 @@ peer_query_maj23_sleep_duration = 2000
# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). # 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
indexer = "kv" indexer = "kv"
# Comma-separated list of tags to index (by default the only tag is tx hash)
# Comma-separated list of tags to index (by default the only tag is "tx.hash")
# #
# You can also index transactions by height by adding "tx.height" tag here.
#
# It's recommended to index only a subset of tags due to possible memory # It's recommended to index only a subset of tags due to possible memory
# bloat. This is, of course, depends on the indexer's DB and the volume of # bloat. This is, of course, depends on the indexer's DB and the volume of
# transactions. # transactions.
index_tags = "" index_tags = ""
# When set to true, tells indexer to index all tags. Note this may be not
# desirable (see the comment above). IndexTags has a precedence over
# IndexAllTags (i.e. when given both, IndexTags will be indexed).
# When set to true, tells indexer to index all tags (predefined tags:
# "tx.hash", "tx.height" and all tags from DeliverTx responses).
#
# Note this may be not desirable (see the comment above). IndexTags has a
# precedence over IndexAllTags (i.e. when given both, IndexTags will be
# indexed).
index_all_tags = false index_all_tags = false
##### instrumentation configuration options ##### ##### instrumentation configuration options #####


+ 5
- 0
rpc/client/rpc_test.go View File

@ -351,6 +351,11 @@ func TestTxSearch(t *testing.T) {
assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash)) assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash))
} }
// query by height
result, err = c.TxSearch(fmt.Sprintf("tx.height >= %d", txHeight), true, 1, 30)
require.Nil(t, err, "%+v", err)
require.Len(t, result.Txs, 1)
// we query for non existing tx // we query for non existing tx
result, err = c.TxSearch(fmt.Sprintf("tx.hash='%X'", anotherTxHash), false, 1, 30) result, err = c.TxSearch(fmt.Sprintf("tx.hash='%X'", anotherTxHash), false, 1, 30)
require.Nil(t, err, "%+v", err) require.Nil(t, err, "%+v", err)


+ 1
- 1
rpc/test/helpers.go View File

@ -85,7 +85,7 @@ func GetConfig() *cfg.Config {
globalConfig.P2P.ListenAddress = tm globalConfig.P2P.ListenAddress = tm
globalConfig.RPC.ListenAddress = rpc globalConfig.RPC.ListenAddress = rpc
globalConfig.RPC.GRPCListenAddress = grpc globalConfig.RPC.GRPCListenAddress = grpc
globalConfig.TxIndex.IndexTags = "app.creator" // see kvstore application
globalConfig.TxIndex.IndexTags = "app.creator,tx.height" // see kvstore application
} }
return globalConfig return globalConfig
} }


Loading…
Cancel
Save